wth
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 3s
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 3s
This commit is contained in:
@@ -48,15 +48,33 @@ jobs:
|
||||
for j in $(seq 0 $((repo_count - 1))); do
|
||||
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
||||
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
||||
|
||||
# 1) fetch README explicitly from main
|
||||
readme_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||
"$GITEA_API/repos/$owner/$repo/contents/README.md?ref=main" || echo "{}")
|
||||
content=$(echo "$readme_json" | jq -r .content 2>/dev/null \
|
||||
| base64 -d 2>/dev/null || echo "")
|
||||
|
||||
# DEBUG: only for Zacatel, dump raw
|
||||
if [ "$owner" = "Zacatel" ]; then
|
||||
echo "----- DEBUG [$owner/$repo] RAW README (first 10 lines) -----"
|
||||
echo "$content" | sed -n '1,10p' | sed -n l
|
||||
echo "----- END RAW DEBUG -----"
|
||||
fi
|
||||
|
||||
# 2) normalize BOM and CRLF
|
||||
content=$(echo "$content" \
|
||||
| sed $'1s/^\xEF\xBB\xBF//' \
|
||||
| sed 's/\r$//' )
|
||||
|
||||
# DEBUG: only for Zacatel, dump normalized
|
||||
if [ "$owner" = "Zacatel" ]; then
|
||||
echo "----- DEBUG [$owner/$repo] NORMALIZED README (first 10 lines) -----"
|
||||
echo "$content" | sed -n '1,10p' | sed -n l
|
||||
echo "----- END NORMALIZED DEBUG -----"
|
||||
fi
|
||||
|
||||
# 3) loosened regex to allow whitespace
|
||||
if echo "$content" | grep -qE '^\s*---\s*$' \
|
||||
&& echo "$content" | grep -qE '^\s*gitea:\s*none\s*$' \
|
||||
&& echo "$content" | grep -qE '^\s*include_toc:\s*true\s*$' \
|
||||
@@ -89,10 +107,12 @@ jobs:
|
||||
repo=${repo_full##*/}
|
||||
api="$GITEA_API/repos/$owner/$repo"
|
||||
|
||||
# 1) figure out the default branch
|
||||
default_branch=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
||||
"$api" \
|
||||
| jq -r '.default_branch')
|
||||
|
||||
# 2) delete the latest non-v1.0.0 tag (but ignore if none)
|
||||
latest_tag=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
||||
"$api/tags" \
|
||||
| jq -r '.[0].name // empty')
|
||||
@@ -104,10 +124,12 @@ jobs:
|
||||
|| true
|
||||
fi
|
||||
|
||||
# 3) fetch existing file SHA (if any)
|
||||
url="$api/contents/$TEMPLATE_PATH"
|
||||
sha=$(curl -sSL -H "Authorization: token $TOKEN" "$url" \
|
||||
| jq -r 'select(.sha != null).sha // empty' || true)
|
||||
|
||||
# 4) build our payload
|
||||
if [[ -z "$sha" ]]; then
|
||||
action="Add"
|
||||
msg="Add CI from skins-template"
|
||||
@@ -127,6 +149,7 @@ jobs:
|
||||
'{message: $message, content: $content, sha: $sha, branch: $branch}')
|
||||
fi
|
||||
|
||||
# 5) push it
|
||||
if curl -sSL --fail -X PUT \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
|
||||
Reference in New Issue
Block a user