generated from osc/skins-template
Update .gitea/workflows/test-skins.yml
This commit is contained in:
@@ -141,6 +141,7 @@ jobs:
|
|||||||
- name: Check all links in markdown files
|
- name: Check all links in markdown files
|
||||||
run: |
|
run: |
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
@@ -166,12 +167,12 @@ jobs:
|
|||||||
|
|
||||||
# Extract ALL links from the markdown file
|
# Extract ALL links from the markdown file
|
||||||
# Match both []() and direct URLs - using Perl regex for better handling
|
# Match both []() and direct URLs - using Perl regex for better handling
|
||||||
grep -oP '\]\(([^\)]+)\)' "$md_file" | sed 's/](\(.*\))/\1/' > /tmp/links_$$.txt || true
|
{
|
||||||
|
grep -oP '\]\(([^\)]+)\)' "$md_file" 2>/dev/null | sed 's/](\(.*\))/\1/' || true
|
||||||
|
grep -oP '!\[[^\]]*\]\(([^\)]+)\)' "$md_file" 2>/dev/null | sed 's/!\[.*\](\(.*\))/\1/' || true
|
||||||
|
} > /tmp/links_$$.txt
|
||||||
|
|
||||||
# Also extract image links
|
link_count=$(wc -l < /tmp/links_$$.txt 2>/dev/null || echo "0")
|
||||||
grep -oP '!\[[^\]]*\]\(([^\)]+)\)' "$md_file" | sed 's/!\[.*\](\(.*\))/\1/' >> /tmp/links_$$.txt || true
|
|
||||||
|
|
||||||
link_count=$(wc -l < /tmp/links_$$.txt)
|
|
||||||
|
|
||||||
if [ $link_count -eq 0 ]; then
|
if [ $link_count -eq 0 ]; then
|
||||||
echo " ℹ️ No links found in this file"
|
echo " ℹ️ No links found in this file"
|
||||||
@@ -191,9 +192,17 @@ jobs:
|
|||||||
|
|
||||||
# Check if it's an external URL
|
# Check if it's an external URL
|
||||||
if [[ "$decoded_link" =~ ^https?:// ]]; then
|
if [[ "$decoded_link" =~ ^https?:// ]]; then
|
||||||
# Check external URL with curl
|
# URL-encode the link for curl (convert spaces and special chars)
|
||||||
http_code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$decoded_link" 2>/dev/null)
|
# Use the original encoded link, not the decoded one
|
||||||
if [[ "$http_code" =~ ^2[0-9][0-9]$ ]] || [[ "$http_code" =~ ^3[0-9][0-9]$ ]]; then
|
encoded_url="$link"
|
||||||
|
|
||||||
|
# Check external URL with curl (with User-Agent header for better compatibility)
|
||||||
|
http_code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 \
|
||||||
|
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
|
||||||
|
"$encoded_url" 2>/dev/null || echo "000")
|
||||||
|
|
||||||
|
# Accept 2xx and 3xx status codes as valid
|
||||||
|
if [[ "$http_code" =~ ^[23][0-9][0-9]$ ]]; then
|
||||||
echo " ✅ $decoded_link"
|
echo " ✅ $decoded_link"
|
||||||
else
|
else
|
||||||
echo " ❌ $decoded_link (HTTP $http_code)"
|
echo " ❌ $decoded_link (HTTP $http_code)"
|
||||||
|
|||||||
Reference in New Issue
Block a user