Update .gitea/actions/test-links/action.yml

This commit is contained in:
2025-11-23 15:05:07 +01:00
parent 96da30aabb
commit b17a6fef7c

View File

@@ -99,16 +99,32 @@ runs:
echo " $status $decoded_link" >> /tmp/download_$$.txt
fi
else
# Local file - remove leading slash if present
if [[ "$decoded_link" =~ ^/ ]]; then
file_path="${decoded_link#/}"
# Local file - check via Gitea API
if [[ "$link" =~ ^/ ]]; then
# Absolute path from repo root
api_path="${link#/}"
else
# Relative path from markdown file
md_dir=$(dirname "$md_file")
file_path="$md_dir/$decoded_link"
if [[ "$md_dir" == "." ]]; then
api_path="$link"
else
api_path="${md_dir#./}/$link"
fi
fi
# Check if file exists
if ! [ -f "$file_path" ]; then
# Get repository info from git remote
if [ -z "$REPO_OWNER" ]; then
REPO_OWNER=$(git config --get remote.origin.url | sed -n 's|.*[:/]\([^/]*\)/[^/]*\.git|\1|p' || echo "")
REPO_NAME=$(git config --get remote.origin.url | sed -n 's|.*[:/][^/]*/\([^/]*\)\.git|\1|p' || echo "")
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
fi
# Check file via Gitea API
api_url="http://gitea:3000/api/v1/repos/$REPO_OWNER/$REPO_NAME/contents/$api_path?ref=$GIT_BRANCH"
http_code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$api_url" 2>/dev/null || echo "000")
if ! [[ "$http_code" =~ ^[23][0-9][0-9]$ ]]; then
status="✖ (not found)"
file_has_errors=1
has_errors=1