Skip to content

Commit b2a3dad

Browse files
committed
add lychee broken link approach
1 parent 3d20be0 commit b2a3dad

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

.github/workflows/.lycheeignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# URL patterns to exclude from checking, one regex pattern per line
2+
# These links will be ignored by lychee
3+
4+
# Example domains
5+
^https?://example\.com
6+
^https?://example\.org
7+
8+
# Common temporary URLs or local development URLs
9+
^https?://localhost
10+
^https?://127\.0\.0\.1
11+
^https?://0\.0\.0\.0
12+
13+
# Social media links (often have anti-scraping measures that may cause checks to fail)
14+
^https?://(www\.)?linkedin\.com
15+
^https?://(www\.)?twitter\.com
16+
^https?://(www\.)?facebook\.com
17+
18+
# Files that may have restricted access
19+
\.pdf$
20+
21+
# Local file paths that exist in production but not in CI environment
22+
file:///home/runner/work/eclipse-edc.github.io/eclipse-edc.github.io/content/en/images/edc.schematic.svg
23+
# Exclude all local SVG files as they may be processed during build
24+
file://.*\.svg$
25+
# Exclude content directory files which may be generated during build
26+
file://.*?/content/.*
27+
28+
# GitHub specific patterns to reduce API rate limiting
29+
# These patterns are specifically for repositories that frequently cause 429 errors
30+
^https?://github\.com/git/git/blob/
31+
^https?://raw\.githubusercontent\.com/git/
32+
^https?://api\.github\.com/
33+
34+
# Add project-specific URL patterns to exclude here
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

Comments
 (0)