-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (70 loc) · 2.35 KB
/
check-pr-links.yml
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
name: Check Links In Pull Requests
on:
pull_request:
branches:
- main
# Optionally limit the check to certain file types
# paths:
# - '**/*.md'
# - '**/*.html'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb
with:
persist-credentials: false
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Check out base branch
env:
BASE_REF: ${{github.event.pull_request.base.ref}}
run: git checkout "$BASE_REF"
- name: Dump all links from ${{github.event.pull_request.base.ref}}
uses: lycheeverse/lychee-action@f81112d0d2814ded911bd23e3beaa9dda9093915
with:
args: |
--dump
--include-fragments
.
output: ./existing-links.txt
continue-on-error: true # Don't fail if base branch check has issues
- name: Stash untracked files
run: git stash push --include-untracked
- name: Check out feature branch
env:
HEAD_REF: ${{ github.head_ref }}
run: git checkout "$HEAD_REF"
- name: Apply stashed changes
run: git stash pop || true
- name: Update ignore file
run: |
if [ -f "existing-links.txt" ]; then
cat existing-links.txt >> .lycheeignore
fi
- name: Check links
uses: lycheeverse/lychee-action@f81112d0d2814ded911bd23e3beaa9dda9093915
with:
args: |
--no-progress
--include-fragments
.
- name: Provide helpful failure message
if: failure()
run: |
echo "::error::Link check failed! Please review the broken links reported above."
echo ""
echo "If certain links are valid but fail due to:"
echo "- CAPTCHA challenges"
echo "- IP blocking"
echo "- Authentication requirements"
echo "- Rate limiting"
echo ""
echo "Consider adding them to .lycheeignore to bypass future checks."
echo "Format: Add one URL pattern per line"
exit 1