1
+ name : Check Broken Links
2
+
3
+ on :
4
+ pull_request :
5
+ types : [opened, synchronize, reopened]
6
+ # Optional: Add scheduled checks
7
+ # schedule:
8
+ # - cron: "0 0 * * 0" # Runs once every Sunday
9
+
10
+ jobs :
11
+ check-links :
12
+ runs-on : ubuntu-latest
13
+ permissions :
14
+ contents : read
15
+
16
+ steps :
17
+ - name : Checkout repository
18
+ uses : actions/checkout@v4
19
+
20
+ # Set up caching to reduce API requests
21
+ - name : Restore lychee cache
22
+ uses : actions/cache@v4
23
+ with :
24
+ path : .lycheecache
25
+ key : cache-lychee-${{ github.sha }}
26
+ restore-keys : cache-lychee-
27
+
28
+ - name : Setup link exclusion patterns (optional)
29
+ id : setup-exclude
30
+ run : |
31
+ if [ -f .lycheeignore ]; then
32
+ echo "Exclusion patterns found in .lycheeignore"
33
+ else
34
+ echo "# Add URL regex patterns to exclude, one per line" > .lycheeignore
35
+ echo "# Example: ^https://example.com" >> .lycheeignore
36
+ fi
37
+
38
+ - name : Link Checker
39
+ id : lychee
40
+ uses : lycheeverse/lychee-action@v2
41
+ env :
42
+ GITHUB_TOKEN : ${{ github.token }}
43
+ with :
44
+ args : >-
45
+ --cache
46
+ --max-cache-age 48h
47
+ --verbose
48
+ --no-progress
49
+ --exclude-path ".git"
50
+ --exclude-path "node_modules"
51
+ --max-retries 5
52
+ --timeout 30
53
+ --max-concurrency 8
54
+ --retry-wait-time 3
55
+ './**/*.md'
56
+ './**/*.html'
57
+ './**/*.txt'
58
+ fail : true
59
+ format : markdown
60
+ output : ./lychee-report.md
61
+
62
+ # If you want to post check results as PR comments, uncomment the following step
63
+ # - name: Create Comment
64
+ # uses: peter-evans/create-or-update-comment@v3
65
+ # if: github.event_name == 'pull_request' && steps.lychee.outputs.exit_code != 0
66
+ # with:
67
+ # issue-number: ${{ github.event.pull_request.number }}
68
+ # body-file: ./lychee-report.md
0 commit comments