File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Links
2+
3+ on :
4+ workflow_dispatch :
5+
6+ concurrency :
7+ group : links
8+ cancel-in-progress : false
9+
10+ jobs :
11+ links :
12+ name : Links
13+ runs-on : ubuntu-latest
14+ permissions :
15+ actions : read
16+ packages : read
17+ contents : read
18+ steps :
19+ -
20+ name : Checkout
21+ uses : actions/checkout@v6
22+ with :
23+ fetch-depth : 0
24+ -
25+ name : Validate Links
26+ run : |
27+ errors=0
28+ count=0
29+ host=""
30+ declare -A seen
31+ check() {
32+ local url="$1" http
33+ http=$(curl -sSL -o /dev/null -w "%{http_code}" --max-time 10 -I -- "$url" 2>&1) || http="000"
34+ [[ "$http" == 2* ]] && return 0
35+ http=$(curl -sSL -o /dev/null -w "%{http_code}" --max-time 10 -r "0-0" -- "$url" 2>&1) || http="000"
36+ [[ "$http" == 2* ]]
37+ }
38+ while IFS= read -r line; do
39+ if [[ "$line" =~ ^[[:space:]]*local[[:space:]]+host=\"(https://[^\"]+)\" ]]; then
40+ host="${BASH_REMATCH[1]%/}"
41+ continue
42+ fi
43+ [[ "$line" =~ ^[[:space:]]*url=\"(.+)\" ]] || continue
44+ val="${BASH_REMATCH[1]#/}"
45+ if [[ "$val" == https://* ]]; then
46+ url="$val"
47+ elif [[ -n "$host" ]]; then
48+ url="$host/$val"
49+ else
50+ continue
51+ fi
52+ [[ -v seen[$url] ]] && continue
53+ seen[$url]=1
54+ count=$((count + 1))
55+ if check "$url"; then
56+ echo " OK: $url"
57+ else
58+ echo "FAIL: $url"
59+ errors=$((errors + 1))
60+ fi
61+ done < "src/define.sh"
62+ echo ""
63+ printf '%d/%d links valid\n' "$(( count - errors ))" "$count"
64+ (( errors == 0 ))
You can’t perform that action at this time.
0 commit comments