Skip to content

Commit d2fd589

Browse files
Check for broken links
1 parent b8b1299 commit d2fd589

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.github/workflows/check-links.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Check that all links are valid, i.e. not broken
2+
name: Check links
3+
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
check-links:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
# The link checker will only work if mlc_config.json is a valid JSON
17+
- name: Validate JSON
18+
uses: docker://orrosenblatt/validate-json-action:latest
19+
env:
20+
INPUT_SCHEMA: .github/workflows/valid_json_schema.json
21+
INPUT_JSONS: mlc_config.json
22+
23+
# These are status code that cannot be ignored.
24+
#
25+
# If there is a valid external link that fails,
26+
# add it to mlc_config.json
27+
- name: External links must be checked, do not allow '0' in the 'aliveStatusCodes' of mlc_config.json
28+
run: if [[ $(grep --regexp "[^0-9]0[^0-9]" mlc_config.json | wc --lines) == "1" ]]; then echo "FOUND"; exit 42; fi
29+
30+
- name: Internal links must checked, do not allow '400' in the 'aliveStatusCodes' of mlc_config.json
31+
run: if [[ $(grep --regexp "[^0-9]400[^0-9]" mlc_config.json | wc --lines) == "1" ]]; then echo "FOUND"; exit 42; fi
32+
33+
34+
- uses: gaurav-nelson/github-action-markdown-link-check@v1
35+
with:
36+
config-file: 'mlc_config.json'
37+
use-quiet-mode: 'yes'
38+
use-verbose-mode: 'no'
39+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"properties": {
3+
"foo": { "type": "string" },
4+
"bar": { "type": "number" }
5+
}
6+
}

mlc_config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"aliveStatusCodes": [200, 403, 418, 500, 503]
3+
}

0 commit comments

Comments
 (0)