Skip to content
Open
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a05c8e3
feat: add broken link checker
Abhijeet2409 Mar 28, 2026
01a9f0c
chore: add and configure broken link checker workflow (weekly schedule)
Abhijeet2409 Mar 28, 2026
dcf7e69
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Mar 31, 2026
ad41d12
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Apr 1, 2026
7158423
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Apr 3, 2026
6ebac06
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Apr 4, 2026
4418a12
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Apr 9, 2026
0949095
fix: update runner
Abhijeet2409 May 6, 2026
4efb2b3
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 May 6, 2026
7ffcdbe
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 May 11, 2026
cb25b45
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 May 16, 2026
1715a12
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 May 26, 2026
ff15b34
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 6, 2026
25cd393
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 11, 2026
fd62b7a
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 12, 2026
393ae9e
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 15, 2026
f3593ee
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 17, 2026
747b3e8
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 18, 2026
152de79
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 21, 2026
071ee95
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 24, 2026
37f9ab1
Merge branch 'main' into fix-broken-links-workflow
Abhijeet2409 Jun 27, 2026
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
103 changes: 103 additions & 0 deletions .github/workflows/check-broken-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Cron – Check Broken Markdown Links

on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
inputs:
dry_run:
description: "Run without creating issues? (true/false)"
required: true
default: true
type: boolean

permissions:
contents: read
issues: write

jobs:
cron-check-broken-links:
runs-on: ubuntu-latest
Comment thread
Abhijeet2409 marked this conversation as resolved.
Outdated
steps:
- name: Harden runner (audit outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Check Markdown links (Lychee)
id: lychee
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
continue-on-error: true
with:
args: --verbose --no-progress './**/*.md'
fail: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Report Broken Links (Idempotent Issue Management)
if: steps.lychee.outcome == 'failure'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
// Determine if this is a dry run
const isManual = context.eventName === 'workflow_dispatch';
const dryRun = isManual ? String(context.payload.inputs.dry_run).toLowerCase() === 'true' : false;

// Labels configuration
const targetLabels = ['broken-markdown-links', 'automated'];
const issueTitle = "Scheduled Markdown Link Check Found Broken Links";
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;

console.log(`Event: ${context.eventName}, Dry Run: ${dryRun}`);

// Define Issue Body
const body = `### 🔗 Broken Links Detected\n\n` +
`The scheduled markdown link check workflow has detected broken links.\n\n` +
`**Run Details:**\n` +
`- **Timestamp:** ${new Date().toISOString()}\n` +
`- **Workflow Run:** [View Logs](${runUrl})\n\n` +
`> **Note:** We use [Lychee](https://github.com/lycheeverse/lychee) for link checking. ` +
`Please check the "Check Markdown links" step in the logs to see the specific URLs that failed.`;

if (dryRun) {
console.log("DRY RUN: Would have created or updated an issue.");
return;
}

// Search for existing issue and Update/Create
try {
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: targetLabels.join(','),
per_page: 100
});

const existingIssue = issues.find(issue => issue.title === issueTitle);

if (existingIssue) {
console.log(`Updating existing issue #${existingIssue.number}`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `**Update ${new Date().toISOString()}:** Still finding broken links.\nCheck new run logs: ${runUrl}`
});
} else {
console.log("Creating a new issue...");
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: body,
labels: targetLabels
});
}
} catch (error) {
console.error('Failed to manage broken link issue:', error);
core.setFailed(`Failed to create or update issue: ${error.message}`);
}
Comment thread
danielmarv marked this conversation as resolved.
Loading