-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
102 lines (88 loc) · 3.11 KB
/
lint-external-links.yml
File metadata and controls
102 lines (88 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Check External Links
on:
# Run weekly on Sundays at 2 AM UTC
schedule:
- cron: '0 2 * * 0'
# Allow manual triggering
workflow_dispatch:
# Run on PRs that modify docs (non-blocking)
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
# Job for PRs: check only changed files
check-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Get changed files
id: changed
run: |
FILES=$(git diff --name-only --diff-filter=AMR origin/${{ github.base_ref }}...HEAD -- '*.md' '*.mdx' || true)
if [ -z "$FILES" ]; then
echo "files=" >> $GITHUB_OUTPUT
echo "No markdown files changed"
else
echo "files<<EOF" >> $GITHUB_OUTPUT
echo "$FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Changed files:"
echo "$FILES"
fi
- name: Restore lychee cache
if: steps.changed.outputs.files != ''
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .lycheecache
key: lychee-cache-
restore-keys: lychee-cache-
- name: Check external links
if: steps.changed.outputs.files != ''
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2
with:
args: --verbose --no-progress ${{ steps.changed.outputs.files }}
fail: true
failIfEmpty: false
jobSummary: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Job for scheduled/manual runs: check all files, create issue
check-full:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# Cache strategy: see lychee.toml for details
# - Restore previous cache so successful checks are skipped
# - Transient errors (429, 5xx) are excluded from cache and retried
# - Save updated cache for next run
- name: Restore lychee cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .lycheecache
key: lychee-cache-
restore-keys: lychee-cache-
- name: Check external links
id: lychee
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2
with:
args: --verbose .
output: ./lychee-report.md
format: markdown
fail: true
jobSummary: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save lychee cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
if: always()
with:
path: .lycheecache
key: lychee-cache-${{ github.run_id }}