-
Notifications
You must be signed in to change notification settings - Fork 6
140 lines (127 loc) · 4.1 KB
/
check-links.yml
File metadata and controls
140 lines (127 loc) · 4.1 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
name: Check Links
on:
push:
branches: [main]
paths:
- "**.md"
- "docs/**"
- ".github/workflows/check-links.yml"
- ".lycheeignore"
pull_request:
branches: [main]
paths:
- "**.md"
- "docs/**"
schedule:
# Run weekly on Mondays at 9 AM UTC to catch dead external links
- cron: "0 9 * * 1"
workflow_dispatch:
jobs:
check-internal-links:
name: Check Internal Markdown Links
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Restore lychee cache
uses: actions/cache@v5
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- name: Check internal links with lychee
uses: lycheeverse/lychee-action@v2
with:
# Only check internal links (file:// scheme)
args: >-
--verbose
--no-progress
--cache
--max-cache-age 1d
--scheme file
--include-fragments
--exclude-path node_modules
--exclude-path .git
'**/*.md'
format: markdown
output: lychee-internal.md
fail: true
jobSummary: true
- name: Upload internal link report
if: always()
uses: actions/upload-artifact@v7
with:
name: lychee-internal-report
path: lychee-internal.md
retention-days: 7
check-external-links:
name: Check External URLs
runs-on: ubuntu-latest
# Only run on schedule or manual trigger to avoid rate limits
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Restore lychee cache
uses: actions/cache@v5
with:
path: .lycheecache
key: cache-lychee-external-${{ github.sha }}
restore-keys: cache-lychee-external-
- name: Check external links with lychee
uses: lycheeverse/lychee-action@v2
with:
# Only check external links (http/https schemes)
args: >-
--verbose
--no-progress
--cache
--max-cache-age 1d
--scheme https
--scheme http
--exclude-path node_modules
--exclude-path .git
--exclude '^http://localhost'
--exclude '^https://localhost'
--timeout 20
--max-concurrency 10
--accept 200,206,301,302,307,308,429,999
--header 'accept=*/*'
'**/*.md'
format: markdown
output: lychee-external.md
fail: false
jobSummary: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload external link report
if: always()
uses: actions/upload-artifact@v7
with:
name: lychee-external-report
path: lychee-external.md
retention-days: 30
link-check-summary:
name: Link Check Summary
runs-on: ubuntu-latest
needs: [check-internal-links, check-external-links]
if: always()
steps:
- name: Summary
run: |
echo "## Link Check Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.check-internal-links.result }}" == "success" ]]; then
echo "✅ Internal links: PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Internal links: FAILED" >> $GITHUB_STEP_SUMMARY
fi
if [[ "${{ needs.check-external-links.result }}" == "success" ]]; then
echo "✅ External URLs: PASSED" >> $GITHUB_STEP_SUMMARY
elif [[ "${{ needs.check-external-links.result }}" == "skipped" ]]; then
echo "⏭️ External URLs: SKIPPED (only runs on schedule)" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ External URLs: COMPLETED WITH WARNINGS" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "📄 Check uploaded artifacts for detailed reports" >> $GITHUB_STEP_SUMMARY