Broken Link Checker #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Broken Link Checker | |
| on: | |
| pull_request: | |
| paths: | |
| - '**/*.md' | |
| workflow_dispatch: | |
| jobs: | |
| markdown-link-check: | |
| name: Check Markdown Broken Links | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get Added/Modified Markdown Files (PR only) | |
| id: changed-files | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| git fetch origin ${{ github.base_ref }} | |
| files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '\.md$' || true) | |
| echo "md_files<<EOF" >> $GITHUB_OUTPUT | |
| echo "$files" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Strip HTML Comments from Changed Markdown Files (PR only) | |
| if: github.event_name == 'pull_request' && steps.changed-files.outputs.md_files != '' | |
| run: | | |
| mkdir sanitized_md | |
| for file in ${{ steps.changed-files.outputs.md_files }}; do | |
| mkdir -p "sanitized_md/$(dirname "$file")" | |
| sed '/<!--/,/-->/d' "$file" > "sanitized_md/$file" | |
| done | |
| - name: Check Broken Links in Added/Modified Files (PR) | |
| if: github.event_name == 'pull_request' && steps.changed-files.outputs.md_files != '' | |
| uses: lycheeverse/[email protected] | |
| with: | |
| args: > | |
| --verbose --exclude-mail --no-progress --exclude ^https?:// | |
| sanitized_md/**/*.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Strip HTML Comments from All Markdown Files (Manual) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| mkdir sanitized_md | |
| for file in $(find . -name "*.md"); do | |
| mkdir -p "sanitized_md/$(dirname "$file")" | |
| sed '/<!--/,/-->/d' "$file" > "sanitized_md/$file" | |
| done | |
| - name: Check Broken Links in Entire Repo (Manual) | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: lycheeverse/[email protected] | |
| with: | |
| args: > | |
| --verbose --exclude-mail --no-progress --exclude ^https?:// | |
| sanitized_md/**/*.md | |
| output: lychee/out.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |