Update .gitea/workflows/deploy-ci.yaml
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 4s
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 4s
This commit is contained in:
@@ -17,7 +17,8 @@ jobs:
|
|||||||
- name: Fetch CI template via Gitea API
|
- name: Fetch CI template via Gitea API
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
resp=$(curl -sSL -H "Authorization: token $TOKEN" "$GITEA_API/repos/osc/skins-template/contents/$TEMPLATE_PATH?ref=main")
|
resp=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
|
"$GITEA_API/repos/osc/skins-template/contents/$TEMPLATE_PATH?ref=main")
|
||||||
template_b64=$(echo "$resp" | jq -r .content)
|
template_b64=$(echo "$resp" | jq -r .content)
|
||||||
echo "TEMPLATE_B64=$template_b64" >> $GITHUB_ENV
|
echo "TEMPLATE_B64=$template_b64" >> $GITHUB_ENV
|
||||||
|
|
||||||
@@ -27,18 +28,21 @@ jobs:
|
|||||||
page=1
|
page=1
|
||||||
per_page=50
|
per_page=50
|
||||||
valid_repos_file=$(mktemp)
|
valid_repos_file=$(mktemp)
|
||||||
user_count_total=$(curl -sSL -H "Authorization: token $TOKEN" "$GITEA_API/admin/users" | jq 'length')
|
user_count_total=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
|
"$GITEA_API/admin/users" | jq 'length')
|
||||||
user_counter=1
|
user_counter=1
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
users_json=$(curl -sSL -H "Authorization: token $TOKEN" "$GITEA_API/admin/users?limit=$per_page&page=$page")
|
users_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
|
"$GITEA_API/admin/users?limit=$per_page&page=$page")
|
||||||
users_count=$(echo "$users_json" | jq 'length')
|
users_count=$(echo "$users_json" | jq 'length')
|
||||||
[ "$users_count" -eq 0 ] && break
|
[ "$users_count" -eq 0 ] && break
|
||||||
|
|
||||||
for i in $(seq 0 $((users_count - 1))); do
|
for i in $(seq 0 $((users_count - 1))); do
|
||||||
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
||||||
echo "[$user_counter/$user_count_total] Processing user: $user_login"
|
echo "[$user_counter/$user_count_total] Processing user: $user_login"
|
||||||
repos_json=$(curl -sSL -H "Authorization: token $TOKEN" "$GITEA_API/users/$user_login/repos")
|
repos_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
|
"$GITEA_API/users/$user_login/repos")
|
||||||
repo_count=$(echo "$repos_json" | jq 'length')
|
repo_count=$(echo "$repos_json" | jq 'length')
|
||||||
|
|
||||||
if [ "$repo_count" -eq 0 ]; then
|
if [ "$repo_count" -eq 0 ]; then
|
||||||
@@ -49,36 +53,13 @@ jobs:
|
|||||||
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
||||||
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
||||||
|
|
||||||
# 1) fetch README explicitly from main
|
|
||||||
readme_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
readme_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
"$GITEA_API/repos/$owner/$repo/contents/README.md?ref=main" || echo "{}")
|
"$GITEA_API/repos/$owner/$repo/contents/README.md?ref=main" \
|
||||||
|
|| echo "{}")
|
||||||
content=$(echo "$readme_json" | jq -r .content 2>/dev/null \
|
content=$(echo "$readme_json" | jq -r .content 2>/dev/null \
|
||||||
| base64 -d 2>/dev/null || echo "")
|
| base64 -d 2>/dev/null || echo "")
|
||||||
|
|
||||||
# DEBUG: only for Zacatel, dump raw
|
if echo "$content" | grep -qE '^[[:space:]]*#[[:space:]]*Skins[[:space:]]*$'; then
|
||||||
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*$' \
|
|
||||||
&& echo "$content" | grep -qE '^\s*#\s*Skins'; then
|
|
||||||
echo "$owner/$repo" >> "$valid_repos_file"
|
echo "$owner/$repo" >> "$valid_repos_file"
|
||||||
echo "added $owner/$repo"
|
echo "added $owner/$repo"
|
||||||
repo_matched=true
|
repo_matched=true
|
||||||
@@ -107,15 +88,11 @@ jobs:
|
|||||||
repo=${repo_full##*/}
|
repo=${repo_full##*/}
|
||||||
api="$GITEA_API/repos/$owner/$repo"
|
api="$GITEA_API/repos/$owner/$repo"
|
||||||
|
|
||||||
# 1) figure out the default branch
|
|
||||||
default_branch=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
default_branch=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
||||||
"$api" \
|
"$api" | jq -r '.default_branch')
|
||||||
| 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" \
|
latest_tag=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
||||||
"$api/tags" \
|
"$api/tags" | jq -r '.[0].name // empty')
|
||||||
| jq -r '.[0].name // empty')
|
|
||||||
|
|
||||||
if [[ -n "$latest_tag" && "$latest_tag" != "v1.0.0" ]]; then
|
if [[ -n "$latest_tag" && "$latest_tag" != "v1.0.0" ]]; then
|
||||||
curl -sSL -X DELETE -H "Authorization: token $TOKEN" \
|
curl -sSL -X DELETE -H "Authorization: token $TOKEN" \
|
||||||
@@ -124,12 +101,10 @@ jobs:
|
|||||||
|| true
|
|| true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3) fetch existing file SHA (if any)
|
|
||||||
url="$api/contents/$TEMPLATE_PATH"
|
url="$api/contents/$TEMPLATE_PATH"
|
||||||
sha=$(curl -sSL -H "Authorization: token $TOKEN" "$url" \
|
sha=$(curl -sSL -H "Authorization: token $TOKEN" "$url" \
|
||||||
| jq -r 'select(.sha != null).sha // empty' || true)
|
| jq -r 'select(.sha != null).sha // empty' || true)
|
||||||
|
|
||||||
# 4) build our payload
|
|
||||||
if [[ -z "$sha" ]]; then
|
if [[ -z "$sha" ]]; then
|
||||||
action="Add"
|
action="Add"
|
||||||
msg="Add CI from skins-template"
|
msg="Add CI from skins-template"
|
||||||
@@ -149,18 +124,14 @@ jobs:
|
|||||||
'{message: $message, content: $content, sha: $sha, branch: $branch}')
|
'{message: $message, content: $content, sha: $sha, branch: $branch}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5) push it
|
|
||||||
if curl -sSL --fail -X PUT \
|
if curl -sSL --fail -X PUT \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$payload" \
|
-d "$payload" "$url" >/dev/null; then
|
||||||
"$url" \
|
|
||||||
>/dev/null; then
|
|
||||||
echo "✅ $action $owner/$repo on branch $default_branch"
|
echo "✅ $action $owner/$repo on branch $default_branch"
|
||||||
else
|
else
|
||||||
echo "❌ $action failed for $owner/$repo → $url" >&2
|
echo "❌ $action failed for $owner/$repo → $url" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
|
|||||||
Reference in New Issue
Block a user