File tree Expand file tree Collapse file tree 4 files changed +73
-2
lines changed
Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+ set -u
5+ [ -n " ${DEBUG:- } " ] && set -x || true
6+
7+ function gherr() {
8+ local line=" $1 "
9+ local file=" ${line%%:* } "
10+ local lineno=" ${line#*: } "
11+ lineno=" ${lineno%%:* } "
12+ local matching=" ${line#*:*: } "
13+ echo " ::error file=${file# ./ } ,line=$lineno ::Broken link $matching "
14+ }
15+
16+ function check() {
17+ local line dir link target failed=0
18+
19+ while read line; do
20+ dir=" $( dirname " ${line%%:* } " ) "
21+ link=" ${line#*:*: } "
22+
23+ case " $link " in
24+ //* )
25+ # ignore http links
26+ ;;
27+ /* )
28+ fail " Not a valid local link"
29+ ;;
30+ ../* )
31+ target=" $( dirname " $dir " ) ${link# ..} "
32+ if ! [ -f " $target " ]; then
33+ failed=1
34+ gherr " $line "
35+ fi
36+ ;;
37+ * )
38+ # relative to current directory
39+ target=" $dir /${link# ./ } "
40+ if ! [ -f " $target " ]; then
41+ failed=1
42+ gherr " $line "
43+ fi
44+ ;;
45+ esac
46+ done
47+
48+ exit " $failed "
49+ }
50+
51+ find . -name ' *.md' -print0 | xargs -0 /usr/bin/grep -Hno ' [^(): ][^():]*\.md' | check
Original file line number Diff line number Diff line change 1+ name : Local Link Checker
2+
3+ on :
4+ push :
5+ branches :
6+ - " *"
7+ pull_request :
8+
9+ jobs :
10+ local-link-checker :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v3
15+
16+ - name : run checker
17+ run : .github/scripts/local-link-checker.sh
18+
19+ - name : info for fixing
20+ if : ${{ failure() }}
21+ run : echo "::error::Broken local links found, please use ./.github/scripts/local-link-checker.sh to check locally"
Original file line number Diff line number Diff line change 33.DS_Store
44* .pdf
55* .patch
6- * .sh
Original file line number Diff line number Diff line change @@ -90,4 +90,4 @@ The arguments used here are:
9090* [2]: [CKB VM version selection][2]
9191
9292[1]: ../0014-vm-cycle-limits/0014-vm-cycle-limits.md
93- [2]: ../0232 -ckb-vm-version-selection/0232 -ckb-vm-version-selection.md
93+ [2]: ../0032 -ckb-vm-version-selection/0032 -ckb-vm-version-selection.md
You can’t perform that action at this time.
0 commit comments