-
Notifications
You must be signed in to change notification settings - Fork 17
49 lines (41 loc) · 1.31 KB
/
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
name: Check docs links
on:
pull_request:
branches:
- main
- feature/*
paths:
- docs/**
jobs:
check-docs-links:
if: github.repository_owner == 'AlexsLemonade'
runs-on: ubuntu-latest
name: Check links
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install python dependencies
run: |
pip install -r docs/requirements.txt
- name: Find all the broken links
id: find_links
run: |
# Build the site and save log output
mkdocs build &> build-log.txt
# Capture all the bad links (don't let grep exit -1 if no match)
grep "relative link" build-log.txt > bad_links.txt || true
grep "no such anchor" build-log.txt >> bad_links.txt || true
# Save the number of bad links to github output
echo "n_bad_links=$(wc -l < bad_links.txt)" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: bad_links
path: bad_links.txt
- name: Fail if there are bad links
if: steps.find_links.outputs.n_bad_links > 0
run: |
echo "There were ${{ steps.find_links.outputs.n_bad_links }} link errors"
cat bad_links.txt
exit 1