-
Notifications
You must be signed in to change notification settings - Fork 23
69 lines (57 loc) · 1.97 KB
/
pr-check-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
name: Check links in diffs
on:
pull_request:
branches: [main]
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Check out main branch
run: git checkout main
- name: Dump all links from main
id: dump_links_from_main
uses: lycheeverse/[email protected]
with:
args: |
--dump
--include-fragments
--exclude-path ./themes/
--exclude-path ./layouts/
.
output: ./links-main.txt
- name: Print links-main.txt in main
run: cat links-main.txt
- name: Stash untracked files
run: git stash push --include-untracked
- name: Check out feature branch
run: git checkout ${{ github.head_ref }}
- name: Apply stashed changes
# Apply stashed changes, ignore errors if stash is empty
run: git stash pop || true
- name: Append links-main.txt to .lycheeignore
run: cat links-main.txt >> .lycheeignore
- name: Check .lycheeignore content
run: cat .lycheeignore
- name: Check links
uses: lycheeverse/[email protected]
with:
args: |
--no-progress
--include-fragments
--exclude-path ./themes/
--exclude-path ./layouts/
.
fail: true # Fail action if broken links are found
- name: Suggestions
if: failure()
run: |
echo -e "\nPlease review the links reported in the Check links step above."
echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc.,"
echo -e "consider adding such links to the .lycheeignore file to bypass future checks.\n"
exit 1