|
1 | | -name: Markdown Links Checker |
| 1 | +name: Daily Broken Link Check |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - paths: |
6 | | - - '**/*.md' |
| 4 | + schedule: |
| 5 | + - cron: '0 2 * * *' # Every day at 2:00 AM UTC |
| 6 | + workflow_dispatch: # Optional: allows manual run |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - Validate_Markdown_Links: |
| 9 | + lychee: |
| 10 | + name: Broken Link Checker |
10 | 11 | runs-on: ubuntu-latest |
11 | 12 |
|
12 | 13 | steps: |
13 | | - - name: Checkout Repository |
| 14 | + - name: Checkout code |
14 | 15 | uses: actions/checkout@v4 |
15 | | - with: |
16 | | - fetch-depth: 0 # important to allow full diff |
17 | | - |
18 | | - - name: Get changed Markdown files |
19 | | - id: changed-files |
20 | | - run: | |
21 | | - git fetch origin ${{ github.base_ref }} |
22 | | - files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '\.md$' || true) |
23 | | - echo "md_files<<EOF" >> $GITHUB_OUTPUT |
24 | | - echo "$files" >> $GITHUB_OUTPUT |
25 | | - echo "EOF" >> $GITHUB_OUTPUT |
26 | 16 |
|
27 | | - - name: Run Lychee on changed Markdown files (internal links only) |
28 | | - if: steps.changed-files.outputs.md_files != '' |
| 17 | + - name: Run Lychee link checker |
| 18 | + id: lychee |
29 | 19 | uses: lycheeverse/[email protected] |
30 | 20 | with: |
31 | 21 | args: > |
32 | 22 | --verbose |
33 | 23 | --exclude-mail |
34 | 24 | --no-progress |
35 | 25 | --exclude ^https?:// |
36 | | - ${{ steps.changed-files.outputs.md_files }} |
| 26 | + --output lychee/out.md |
| 27 | + '**/*.md' |
37 | 28 | env: |
38 | 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Create or update GitHub Issue if broken links found |
| 32 | + if: failure() # Only runs if Lychee exits with error (broken links found) |
| 33 | + uses: peter-evans/create-issue-from-file@v4 |
| 34 | + with: |
| 35 | + title: "🚨 Broken Links Detected" |
| 36 | + content-filepath: lychee/out.md |
| 37 | + labels: bug, links |
| 38 | + assignees: your-github-username # optional: assign to yourself |
| 39 | + update-existing: true # ✅ Avoids duplicate issues |
| 40 | + issue-pattern: "Broken Links Detected" # Matches existing issue title |
0 commit comments