Update .gitea/actions/test-links/action.yml
This commit is contained in:
@@ -99,16 +99,32 @@ runs:
|
|||||||
echo " $status $decoded_link" >> /tmp/download_$$.txt
|
echo " $status $decoded_link" >> /tmp/download_$$.txt
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Local file - remove leading slash if present
|
# Local file - check via Gitea API
|
||||||
if [[ "$decoded_link" =~ ^/ ]]; then
|
if [[ "$link" =~ ^/ ]]; then
|
||||||
file_path="${decoded_link#/}"
|
# Absolute path from repo root
|
||||||
|
api_path="${link#/}"
|
||||||
else
|
else
|
||||||
|
# Relative path from markdown file
|
||||||
md_dir=$(dirname "$md_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
|
fi
|
||||||
|
|
||||||
# Check if file exists
|
# Get repository info from git remote
|
||||||
if ! [ -f "$file_path" ]; then
|
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)"
|
status="✖ (not found)"
|
||||||
file_has_errors=1
|
file_has_errors=1
|
||||||
has_errors=1
|
has_errors=1
|
||||||
|
|||||||
Reference in New Issue
Block a user