Testing links v2 #11
Workflow file for this run
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: Check Links In Pull Requests | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '**/*.md' | |
| jobs: | |
| check-links: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout repo | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Find changed Markdown files | |
| - name: Get changed Markdown files | |
| id: changed-files | |
| run: | | |
| files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.head_ref }} | grep '\.md$' || true) | |
| echo "changed_files=$files" >> $GITHUB_ENV | |
| echo "Changed Markdown files:" | |
| echo "$files" | |
| # Skip if no Markdown files | |
| - name: Skip if no Markdown files changed | |
| if: ${{ env.changed_files == '' }} | |
| run: | | |
| echo "No Markdown files changed. Skipping link check." | |
| exit 0 | |
| # Run Lychee | |
| - name: Run Lychee link checker | |
| id: lychee | |
| continue-on-error: true | |
| run: | | |
| rm -f lychee-full-report.txt | |
| for f in ${{ env.changed_files }}; do | |
| echo "Checking links in $f" | |
| lychee --no-progress --include-fragments "$f" >> lychee-full-report.txt || true | |
| done | |
| # Extract only broken links for log | |
| if grep -qE "❌|ERROR" lychee-full-report.txt; then | |
| echo "❌ Broken links found:" | |
| grep -E "❌|ERROR" lychee-full-report.txt | |
| else | |
| echo "✅ No broken links found." | |
| fi | |
| # Upload full report as artifact | |
| - name: Upload Lychee full report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lychee-full-report | |
| path: lychee-full-report.txt |