Files
awesome-docker/.github/workflows/broken_links.yml
Julien Bisconti 8bb3147e4e fix: prevent false link-check failures and harden health/workflow errors
Address three review findings from the Go rewrite:\n\n- checker: update PartitionLinks to only classify HTTP(S) URLs as external links.\n  This skips markdown-relative targets (for example  and anchors) so\n  non-URL entries are no longer sent to HTTP validation and do not produce\n  deterministic "unsupported protocol scheme" failures.\n\n- health command: stop ignoring LoadHealthCache errors.\n  Return a user-facing "load cache" error when the cache file is unreadable\n  or invalid instead of allowing a nil cache panic on Merge.\n\n- broken links workflow: remove masked execution behavior from the link check\n  step. Capture awesome-docker check exit code, set has_errors=true on any\n  non-zero exit, and expose the exit code in the generated issue body so\n  checker failures are visible and cannot incorrectly close the tracking issue.\n\nTest coverage updates:\n- extend checker partition test to include markdown-relative/anchor targets\n  and verify they are not treated as external URLs.\n- add cache test for invalid YAML load failure.
2026-02-27 23:45:13 +01:00

103 lines
3.4 KiB
Markdown

name: Broken Links Report
on:
schedule:
- cron: "0 2 * * 6"
workflow_dispatch:
jobs:
check-links:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Build
run: go build -o awesome-docker ./cmd/awesome-docker
- name: Run Link Check
id: link_check
run: |
set +e
./awesome-docker check > link_check_output.txt 2>&1
exit_code=$?
set -e
has_errors=false
if [ "$exit_code" -ne 0 ]; then
has_errors=true
fi
if grep -qi "broken links" link_check_output.txt; then
has_errors=true
fi
echo "has_errors=$has_errors" >> "$GITHUB_OUTPUT"
echo "check_exit_code=$exit_code" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create/Update Issue for Broken Links
if: steps.link_check.outputs.has_errors == 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const output = fs.readFileSync('link_check_output.txt', 'utf8');
const exitCode = '${{ steps.link_check.outputs.check_exit_code }}';
const issueBody = `# Broken Links Detected\n\nThe weekly link check found broken links or the checker failed to execute cleanly.\n\nChecker exit code: ${exitCode}\n\n\`\`\`\n${output}\n\`\`\`\n\n## Action Required\n\n- Update the URL if the resource moved\n- Remove the entry if permanently unavailable\n- Add to \`config/exclude.yaml\` if a known false positive\n- Investigate checker failures when exit code is non-zero\n\n---\n*Auto-generated by broken_links.yml*`;
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'broken-links',
per_page: 1
});
if (issues.data.length > 0) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issues.data[0].number,
body: issueBody
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Broken Links Detected',
body: issueBody,
labels: ['broken-links', 'bug']
});
}
- name: Close Issue if No Errors
if: steps.link_check.outputs.has_errors == 'false'
uses: actions/github-script@v7
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'broken-links',
per_page: 1
});
if (issues.data.length > 0) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issues.data[0].number,
state: 'closed',
state_reason: 'completed'
});
}