generated from osc/skins-template
Update .gitea/workflows/test-skins.yml
This commit is contained in:
@@ -14,7 +14,7 @@ jobs:
|
|||||||
- name: Validate links and assets
|
- name: Validate links and assets
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
RED="\033[31m"
|
RED="\033[31m"
|
||||||
GREEN="\033[32m"
|
GREEN="\033[32m"
|
||||||
@@ -30,10 +30,12 @@ jobs:
|
|||||||
local url="$1"
|
local url="$1"
|
||||||
echo " → Checking external: $url"
|
echo " → Checking external: $url"
|
||||||
|
|
||||||
|
# HEAD request
|
||||||
if curl -Is --max-time 10 "$url" | head -n1 | grep -qE "HTTP/.* (200|30[0-9])"; then
|
if curl -Is --max-time 10 "$url" | head -n1 | grep -qE "HTTP/.* (200|30[0-9])"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# GET fallback
|
||||||
if curl -Is --max-time 10 -X GET "$url" | head -n1 | grep -qE "HTTP/.* (200|30[0-9])"; then
|
if curl -Is --max-time 10 -X GET "$url" | head -n1 | grep -qE "HTTP/.* (200|30[0-9])"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -56,44 +58,38 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
extract_links() {
|
extract_links() {
|
||||||
local file="$1"
|
local f="$1"
|
||||||
|
|
||||||
grep -oE '\[[^]]*\]\([^)]*\)' "$file" \
|
grep -oE '\[[^]]*\]\([^)]*\)' "$f" \
|
||||||
| sed -E 's/.*\((.*)\).*/\1/'
|
| sed -E 's/.*\((.*)\).*/\1/'
|
||||||
|
|
||||||
grep -oE '!\[[^]]*\]\([^)]*\)' "$file" \
|
grep -oE '!\[[^]]*\]\([^)]*\)' "$f" \
|
||||||
| sed -E 's/.*\((.*)\).*/\1/'
|
| sed -E 's/.*\((.*)\).*/\1/'
|
||||||
|
|
||||||
grep -oE 'https?://[^ )"]+' "$file"
|
grep -oE 'https?://[^ )"]+' "$f"
|
||||||
|
|
||||||
grep -oE '<img[^>]*src="[^"]+"' "$file" \
|
grep -oE '<img[^>]*src="[^"]+"' "$f" \
|
||||||
| sed -E 's/.*src="([^"]*)".*/\1/'
|
| sed -E 's/.*src="([^"]*)".*/\1/'
|
||||||
|
|
||||||
grep -oE '<video[^>]*src="[^"]+"' "$file" \
|
grep -oE '<video[^>]*src="[^"]+"' "$f" \
|
||||||
| sed -E 's/.*src="([^"]*)".*/\1/'
|
| sed -E 's/.*src="([^"]*)".*/\1/'
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "🔍 Scanning Markdown files..."
|
echo "🔍 Scanning Markdown files..."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
while IFS= read -r mdfile; do
|
find . -type f -name '*.md' | while IFS= read -r mdfile; do
|
||||||
echo "📄 Checking: $mdfile"
|
echo "📄 Checking: $mdfile"
|
||||||
|
|
||||||
while IFS= read -r url; do
|
while IFS= read -r url; do
|
||||||
[[ -z "$url" ]] && continue
|
[[ -z "$url" ]] && continue
|
||||||
[[ "$url" == mailto:* ]] && continue
|
[[ "$url" == mailto:* ]] && continue
|
||||||
|
|
||||||
###
|
# Skip tag links inside /docs → but **do NOT print them**
|
||||||
# 🚫 Skip tag-version links inside /docs/*
|
|
||||||
###
|
|
||||||
if [[ "$mdfile" == ./docs/* ]] && [[ "$url" == *"/src/tag/"* ]]; then
|
if [[ "$mdfile" == ./docs/* ]] && [[ "$url" == *"/src/tag/"* ]]; then
|
||||||
echo " → Skipping tag link (allowed in docs): $url"
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###
|
|
||||||
# Normal link checking
|
|
||||||
###
|
|
||||||
if [[ "$url" == http* ]]; then
|
if [[ "$url" == http* ]]; then
|
||||||
if ! check_http "$url"; then
|
if ! check_http "$url"; then
|
||||||
ERRORS+=("❌ Broken external link: $url (in $mdfile)")
|
ERRORS+=("❌ Broken external link: $url (in $mdfile)")
|
||||||
@@ -107,18 +103,16 @@ jobs:
|
|||||||
done < <(extract_links "$mdfile")
|
done < <(extract_links "$mdfile")
|
||||||
|
|
||||||
echo
|
echo
|
||||||
done < <(find . -type f -name '*.md')
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if (( ${#ERRORS[@]} > 0 )); then
|
if (( ${#ERRORS[@]} > 0 )); then
|
||||||
echo -e "${RED}✖ Broken Links & Missing Files Found:${RESET}"
|
echo -e "${RED}✖ Errors found:${RESET}"
|
||||||
for e in "${ERRORS[@]}"; do
|
printf "%s\n" "${ERRORS[@]}"
|
||||||
echo "$e"
|
|
||||||
done
|
|
||||||
echo
|
echo
|
||||||
echo -e "${RED}⚠️ Job will NOT fail (requested behavior).${RESET}"
|
echo -e "${RED}❌ Failing job because broken links were found.${RESET}"
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
echo -e "${GREEN}✔ All links OK!${RESET}"
|
echo -e "${GREEN}✔ All links OK!${RESET}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user