Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Links
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[yamllint] reported by reviewdog 🐶
[warning] missing document start "---" (document-start)


on:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[yamllint] reported by reviewdog 🐶
[warning] truthy value should be one of [false, true] (truthy)

workflow_dispatch:

concurrency:
group: links
cancel-in-progress: false

jobs:
links:
name: Links
runs-on: ubuntu-latest
permissions:
actions: read
packages: read
contents: read
steps:
-
name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
-
name: Validate Links
run: |
errors=0
count=0
host=""
declare -A seen
check() {
local url="$1" http
http=$(curl -sSL -o /dev/null -w "%{http_code}" --max-time 10 -I -- "$url" 2>&1) || http="000"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[yamllint] reported by reviewdog 🐶
[error] line too long (106 > 80 characters) (line-length)

[[ "$http" == 2* ]] && return 0
http=$(curl -sSL -o /dev/null -w "%{http_code}" --max-time 10 -r "0-0" -- "$url" 2>&1) || http="000"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[yamllint] reported by reviewdog 🐶
[error] line too long (112 > 80 characters) (line-length)

[[ "$http" == 2* ]]
}
while IFS= read -r line; do
if [[ "$line" =~ ^[[:space:]]*local[[:space:]]+host=\"(https://[^\"]+)\" ]]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[yamllint] reported by reviewdog 🐶
[error] line too long (93 > 80 characters) (line-length)

host="${BASH_REMATCH[1]%/}"
continue
fi
[[ "$line" =~ ^[[:space:]]*url=\"(.+)\" ]] || continue
val="${BASH_REMATCH[1]#/}"
if [[ "$val" == https://* ]]; then
url="$val"
elif [[ -n "$host" ]]; then
url="$host/$val"
else
continue
fi
[[ -v seen[$url] ]] && continue
seen[$url]=1
count=$((count + 1))
if check "$url"; then
echo " OK: $url"
else
echo "FAIL: $url"
errors=$((errors + 1))
fi
done < "src/define.sh"
echo ""
printf '%d/%d links valid\n' "$(( count - errors ))" "$count"
(( errors == 0 ))
Loading