Debian Codegraph @

.github/workflows/links-fail-fast.yml

raw
1 name: Links (Fail Fast)
2
3 on:
4 push:
5 branches:
6 - main
7 pull_request:
8
9 # Declare default permissions as read only.
10 permissions: read-all
11
12 jobs:
13 changedfiles:
14 name: changed files
15 runs-on: ubuntu-latest
16 env:
17 PR_HEAD: ${{ github.event.pull_request.head.sha }}
18 outputs:
19 files: ${{ steps.changes.outputs.files }}
20 steps:
21 - name: Checkout Repo
22 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23 with:
24 fetch-depth: 0
25 - name: Get changed files
26 id: changes
27 run: |
28 files=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main $PR_HEAD) $PR_HEAD | xargs)
29
30 # Used for debugging.
31 echo "files=$files"
32
33 echo "files=$files" >> $GITHUB_OUTPUT
34
35 check-links:
36 runs-on: ubuntu-latest
37 needs: changedfiles
38 if: ${{needs.changedfiles.outputs.files}}
39 steps:
40 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
41
42 - name: Restore lychee cache
43 uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
44 id: cache-restore
45 with:
46 path: .lycheecache
47 key: cache-lychee-${{ github.sha }}
48 restore-keys: cache-lychee-
49
50 - name: Link Checker
51 uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
52 env:
53 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 with:
55 fail: true
56 failIfEmpty: false
57 args: --max-concurrency 5 --cache --max-cache-age 1d --cache-exclude-status 300..=599 ${{needs.changedfiles.outputs.files}}
58
59 - name: Save lychee cache
60 if: always()
61 uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
62 with:
63 path: .lycheecache
64 key: ${{ steps.cache-restore.outputs.cache-primary-key }}