-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (41 loc) · 1.84 KB
/
check_links.yaml
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
# Check that all links are valid, i.e. not broken
name: Check links
# Run script on the 1st day of the month.
# 1st as the first letter of this repo is the 1st letter in the alphabet.
on:
push:
pull_request:
schedule:
- cron: "0 0 1 * *"
jobs:
check-links:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
# The link checker will only work if mlc_config.json is a valid JSON
- name: Validate JSON
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: .github/workflows/valid_json_schema.json
INPUT_JSONS: mlc_config.json
# These are status code that cannot be ignored.
#
# If there is a valid external link that fails,
# add it to mlc_config.json
- name: External links must be checked, do not allow '0' in the 'aliveStatusCodes' of mlc_config.json
run: if [[ $(grep --regexp "[^0-9]0[^0-9]" mlc_config.json | wc --lines) == "1" ]]; then echo "FOUND"; exit 42; fi
- name: Internal links must checked, do not allow '400' in the 'aliveStatusCodes' of mlc_config.json
run: if [[ $(grep --regexp "[^0-9]400[^0-9]" mlc_config.json | wc --lines) == "1" ]]; then echo "FOUND"; exit 42; fi
# For an indented block, a link to a broken image is ignored, as the link checker assumes it to be code.
# In our case, it is not: for us, it is usually an admonition (i.e. a 'question' or 'info' block)
# Here all indented text is unindented
# https://github.com/UPPMAX/UPPMAX-documentation/issues/114
- name: unindent text
run: ./scripts/unindent_text.sh
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: 'mlc_config.json'
use-quiet-mode: 'yes'
use-verbose-mode: 'no'