|
| 1 | +name: Markdown Broken Links Checker |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '**/*.md' |
| 7 | + workflow_dispatch: # Manual trigger for full repo check |
| 8 | + |
| 9 | +jobs: |
| 10 | + validate-markdown-links-pr: |
| 11 | + name: Check Broken Links in PR |
| 12 | + if: github.event_name == 'pull_request' |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout Repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Get changed Markdown files |
| 22 | + id: changed-files |
| 23 | + run: | |
| 24 | + git fetch origin ${{ github.base_ref }} |
| 25 | + files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '\.md$' || true) |
| 26 | + echo "md_files<<EOF" >> $GITHUB_OUTPUT |
| 27 | + echo "$files" >> $GITHUB_OUTPUT |
| 28 | + echo "EOF" >> $GITHUB_OUTPUT |
| 29 | +
|
| 30 | + - name: Run Lychee on changed Markdown files (internal links only) |
| 31 | + if: steps.changed-files.outputs.md_files != '' |
| 32 | + uses: lycheeverse/[email protected] |
| 33 | + with: |
| 34 | + args: > |
| 35 | + --verbose |
| 36 | + --exclude-mail |
| 37 | + --no-progress |
| 38 | + --exclude ^https?:// |
| 39 | + ${{ steps.changed-files.outputs.md_files }} |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + validate-markdown-links-fullRepo: |
| 44 | + name: Check Broken Links in Full Repo (Manual) |
| 45 | + if: github.event_name == 'workflow_dispatch' |
| 46 | + runs-on: ubuntu-latest |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout Repository |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Run Lychee on All Markdown Files (internal links only) |
| 53 | + uses: lycheeverse/[email protected] |
| 54 | + with: |
| 55 | + args: > |
| 56 | + --verbose |
| 57 | + --exclude-mail |
| 58 | + --no-progress |
| 59 | + --exclude ^https?:// |
| 60 | + '**/*.md' |
| 61 | + output: lychee/out.md |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments