1- name : Check Links In Pull Requests
1+ name : Check Links
22
33on :
44 pull_request :
5- branches :
6- - main
7- # Optionally limit the check to certain file types
8- # paths:
9- # - '**/*.md'
10- # - '**/*.html'
11-
12- concurrency :
13- group : ${{ github.workflow }}-${{ github.ref }}
14- cancel-in-progress : true
5+ types : [opened, synchronize, reopened]
156
167jobs :
178 check-links :
189 runs-on : ubuntu-latest
19-
2010 steps :
21- - name : Clone repository
22- uses : actions/checkout@v4
23- with :
24- fetch-depth : 0
25- ref : ${{github.event.pull_request.head.ref}}
26- repository : ${{github.event.pull_request.head.repo.full_name}}
27-
28- - name : Check out base branch
29- run : git checkout ${{github.event.pull_request.base.ref}}
30-
31- - name : Dump all links from ${{github.event.pull_request.base.ref}}
32- uses : lycheeverse/lychee-action@v2
11+ - uses : actions/checkout@v4
12+ - uses : lycheeverse/lychee-action@v2
13+ - name : Comment Broken Links
14+ uses : marocchino/sticky-pull-request-comment@v2
3315 with :
34- args : |
35- --dump
36- --include-fragments
37- .
38- output : ./existing-links.txt
39- continue-on-error : true # Don't fail if base branch check has issues
40-
41- - name : Stash untracked files
42- run : git stash push --include-untracked
43-
44- - name : Check out feature branch
45- run : git checkout ${{ github.head_ref }}
46-
47- - name : Apply stashed changes
48- run : git stash pop || true
49-
50- - name : Update ignore file
51- run : |
52- if [ -f "existing-links.txt" ]; then
53- cat existing-links.txt >> .lycheeignore
54- fi
55-
56- - name : Check links
57- uses : lycheeverse/lychee-action@v2
58- with :
59- args : |
60- --no-progress
61- --include-fragments
62- .
63-
64- - name : Provide helpful failure message
65- if : failure()
66- run : |
67- echo "::error::Link check failed! Please review the broken links reported above."
68- echo ""
69- echo "If certain links are valid but fail due to:"
70- echo "- CAPTCHA challenges"
71- echo "- IP blocking"
72- echo "- Authentication requirements"
73- echo "- Rate limiting"
74- echo ""
75- echo "Consider adding them to .lycheeignore to bypass future checks."
76- echo "Format: Add one URL pattern per line"
77- exit 1
16+ path : lychee/out.md
0 commit comments