Skip to content

Commit db2586d

Browse files
committed
Updated config file from lychee docs
1 parent fa01d6f commit db2586d

File tree

1 file changed

+54
-9
lines changed

1 file changed

+54
-9
lines changed
Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,68 @@
11
name: Check Links In Pull Requests
22

3-
on: [pull_request]
3+
on:
4+
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
415

516
jobs:
617
check-links:
718
runs-on: ubuntu-latest
19+
820
steps:
9-
# Step 1: Checkout the repo
10-
- name: Checkout GitHub repo
21+
- name: Clone repository
1122
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
33+
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
1255
13-
# Step 2: Run Lychee to check links
14-
- name: Run Lychee link checker
56+
- name: Check links
1557
uses: lycheeverse/lychee-action@v2
1658
with:
17-
args: "--no-progress --include-fragments 16/**/*.md"
59+
args: |
60+
--no-progress
61+
--include-fragments
62+
.
1863
19-
# Step 3: Provide a helpful message if the check fails
20-
- name: Helpful failure message
21-
if: ${{ failure() }}
64+
- name: Provide helpful failure message
65+
if: failure()
2266
run: |
2367
echo "::error::Link check failed! Please review the broken links reported above."
2468
echo ""
@@ -30,3 +74,4 @@ jobs:
3074
echo ""
3175
echo "Consider adding them to .lycheeignore to bypass future checks."
3276
echo "Format: Add one URL pattern per line"
77+
exit 1

0 commit comments

Comments
 (0)