Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/check-markdown-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Check Markdown Links

on:
workflow_call:
inputs:
config-file:
description: 'Path to markdown-link-check config file. If not found, falls back to inline default config.'
required: false
type: string
default: '.markdown-link-check.json'

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use default config if repo config not found
id: config
shell: bash
run: |
CONFIG_FILE="${{ inputs.config-file }}"
if [ -f "$CONFIG_FILE" ]; then
echo "config-path=$CONFIG_FILE" >> "$GITHUB_OUTPUT"
echo "Using repo config: $CONFIG_FILE"
else
echo "Repo config not found, using inline default config..."
echo '{"retryOn429":true,"retryCount":3,"fallbackRetryDelay":"30s","aliveStatusCodes":[200,206]}' \
> ".markdown-link-check-default.json"
echo "config-path=.markdown-link-check-default.json" >> "$GITHUB_OUTPUT"
echo "Using default config (inline)"
fi

- uses: tcort/github-action-markdown-link-check@e7c7a18363c842693fadde5d41a3bd3573a7a225 # v1.1.2
id: link-check
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: ${{ steps.config.outputs.config-path }}
continue-on-error: true

- name: Create issue if links are broken
if: steps.link-check.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const title = '🔗 Broken markdown links detected';
const label = 'broken-links';

// Check for existing open issue to avoid duplicates
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: label,
});

if (existing.data.length > 0) {
console.log(`Issue already exists: #${existing.data[0].number}`);
return;
}

const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;

await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body: `The weekly markdown link check found broken links.\n\nSee the [workflow run](${runUrl}) for details.`,
labels: [label],
});
42 changes: 42 additions & 0 deletions markdown-link-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Markdown Link Check

Reusable workflow for weekly markdown link checking across Strands Agents repositories.

## Usage

Add this to your repository at `.github/workflows/check-markdown-links.yml`:

```yaml
name: Check Markdown Links

on:
schedule:
- cron: '0 9 * * 1' # Every Monday at 9am UTC
workflow_dispatch:

jobs:
check-links:
uses: strands-agents/devtools/.github/workflows/check-markdown-links.yml@main
```

## Configuration

The workflow uses a default config from this directory. To customize per-repo, add a `.markdown-link-check.json` file to your repository root:

```json
{
"retryOn429": true,
"retryCount": 3,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206]
}
```

If no repo-level config is found, the [default config](./default-config.json) is used automatically.

## How It Works

1. Runs weekly (Monday 9am UTC) or on manual dispatch
2. Scans all markdown files for broken links
3. If broken links are found, creates a GitHub issue with the `broken-links` label
4. Skips issue creation if one already exists (avoids duplicates)
6 changes: 6 additions & 0 deletions markdown-link-check/default-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"retryOn429": true,
"retryCount": 3,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206]
}