Fix broken external links found with automated link checking #52
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 external links | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - '**.md' | |
| - 'docs/**' | |
| - '.github/workflows/check-links.yml' | |
| - 'lychee.toml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| check-links: | |
| name: Check external links in documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| # To clear the lychee cache for a PR, replace `<pull-request-number>` with the PR number and run in pwsh: | |
| # $ids = gh api repos/SteeltoeOSS/Documentation/actions/caches ` | |
| # --paginate ` | |
| # --jq '.actions_caches[] | |
| # | select(.key | startswith("cache-lychee-<pull-request-number>-")) | |
| # | .id' | |
| # $ids | ForEach-Object { | |
| # gh api -X DELETE "repos/SteeltoeOSS/Documentation/actions/caches/$_" | |
| # Write-Host "Deleted cache $_" | |
| # } | |
| - name: Restore lychee cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .lycheecache | |
| key: cache-lychee-${{ github.event.pull_request.number || 'manual' }}-${{ github.sha }} | |
| restore-keys: cache-lychee-${{ github.event.pull_request.number || 'manual' }}- | |
| - name: Check external links with lychee | |
| uses: lycheeverse/lychee-action@v2 | |
| with: | |
| args: --no-progress '**/*.md' | |
| fail: false | |
| failIfEmpty: true | |
| jobSummary: false | |
| - name: Add link checking results to job summary | |
| run: | | |
| if [ -f ./lychee/out.md ]; then | |
| sed 's/^# Summary$/# External link checking results/' ./lychee/out.md | tee -a "$GITHUB_STEP_SUMMARY" > ./lychee/results.md | |
| fi | |
| - name: Comment on PR with link check results | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: mshick/add-pr-comment@v2 | |
| with: | |
| message-id: external-links-check | |
| message-path: ./lychee/results.md |