-
Notifications
You must be signed in to change notification settings - Fork 89
74 lines (68 loc) · 2.74 KB
/
link-check-pr.yml
File metadata and controls
74 lines (68 loc) · 2.74 KB
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
# Pull-request link check.
#
# Scope: external HTTP(S) links in markdown files changed by the PR.
# Internal/relative links are validated by Docusaurus during build.yml
# (onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'throw'); re-checking
# them here would be redundant and prone to false positives because
# lychee cannot replay Docusaurus's slug routing.
name: Link check (PR)
on:
pull_request:
paths:
- '**/*.md'
- '**/*.mdx'
- 'lychee.toml'
- '.github/workflows/link-check-pr.yml'
permissions:
contents: read
jobs:
lychee:
runs-on: ubuntu-latest
# Non-blocking on day one. Once the check is stable for a couple of
# weeks, remove this line and mark "Link check (PR) / lychee" as a
# required status check in branch protection.
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Detect changed markdown files
id: changed
uses: tj-actions/changed-files@v45
with:
files: |
**/*.md
**/*.mdx
- name: Restore lychee cache
if: steps.changed.outputs.any_changed == 'true'
uses: actions/cache@v4
with:
path: .lycheecache
key: lychee-pr-${{ github.run_id }}
restore-keys: lychee-pr-
- name: Run lychee on changed files
if: steps.changed.outputs.any_changed == 'true'
uses: lycheeverse/lychee-action@v2
with:
# --scheme http --scheme https restricts lychee to absolute
# HTTP(S) URLs only (i.e., external links). See header comment.
#
# --root-dir is required so lychee can resolve root-relative
# paths like /docs/... or /img/... that are common in MDX
# (href="/docs/foo", src="/img/bar.svg"). Without it, lychee
# errors at URI construction *before* the --scheme filter runs,
# causing false-positive failures on internal links. With
# --root-dir set, those links become file:// URIs and are then
# correctly filtered out by --scheme http --scheme https.
#
# Must be an absolute path; github.workspace resolves to the
# runner's absolute checkout dir (e.g. /home/runner/work/...).
# Do NOT swap in --base-url here — that would rewrite root-
# relative paths into http(s):// URIs and lychee would actually
# hit them over the network against the canonical site.
args: --no-progress --scheme http --scheme https --root-dir ${{ github.workspace }} --config lychee.toml ${{ steps.changed.outputs.all_changed_files }}
fail: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}