Broken Link Checker #17
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 Repository | |
| 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: Prepare Sanitized Markdown Files (PR) | |
| if: github.event_name == 'pull_request' && steps.changed-files.outputs.md_files != '' | |
| run: | | |
| rsync -av --exclude '.git' --exclude 'node_modules' ./ sanitized_md/ | |
| for file in ${{ steps.changed-files.outputs.md_files }}; do | |
| if [ -f "sanitized_md/$file" ]; then | |
| sed -i -e 's/<!--.*-->//g' -e '/<!--/,/-->/d' "sanitized_md/$file" | |
| fi | |
| done | |
| - name: Run Lychee on Changed Markdown Files (PR) | |
| if: github.event_name == 'pull_request' && steps.changed-files.outputs.md_files != '' | |
| uses: lycheeverse/[email protected] | |
| with: | |
| args: > | |
| --verbose --no-progress --exclude-mail | |
| --exclude ^https?:// | |
| sanitized_md/${{ steps.changed-files.outputs.md_files }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare Sanitized Markdown Files (Manual) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| rsync -av --exclude '.git' --exclude 'node_modules' ./ sanitized_md/ | |
| find sanitized_md -name "*.md" -exec sed -i -e 's/<!--.*-->//g' -e '/<!--/,/-->/d' {} + | |
| - name: Run Lychee on Entire Repo (Manual) | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: lycheeverse/[email protected] | |
| with: | |
| args: > | |
| --verbose --no-progress --exclude-mail | |
| --exclude ^https?:// | |
| 'sanitized_md/**/*.md' | |
| output: lychee/out.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |