add bash as shell
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 4s

This commit is contained in:
2025-06-08 17:10:31 +02:00
parent 24445bb75f
commit efacc4e5d1

View File

@@ -72,6 +72,8 @@ jobs:
- name: Update CI via Gitea API
shell: bash
run: |
set -eo pipefail
mapfile -t repos < "$VALID_REPOS_FILE"
for idx in "${!repos[@]}"; do
repo_full=${repos[$idx]}
@@ -79,22 +81,46 @@ jobs:
repo=${repo_full##*/}
url="$GITEA_API/repos/$owner/$repo/contents/$TEMPLATE_PATH"
tags_resp=$(curl -sSL -H "Authorization: token $TOKEN" "$GITEA_API/repos/$owner/$repo/tags")
latest_tag=$(echo "$tags_resp" | jq -r '.[0].name // ""')
if [ -n "$latest_tag" ] && [ "$latest_tag" != "v1.0.0" ]; then
curl -sSL -X DELETE -H "Authorization: token $TOKEN" "$GITEA_API/repos/$owner/$repo/git/refs/tags/$latest_tag"
latest_tag=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
"$GITEA_API/repos/$owner/$repo/tags" \
| jq -r '.[0].name // empty' )
if [[ -n "$latest_tag" && "$latest_tag" != "v1.0.0" ]]; then
curl -sSL --fail -X DELETE \
-H "Authorization: token $TOKEN" \
"$GITEA_API/repos/$owner/$repo/git/refs/tags/$latest_tag" \
>/dev/null
fi
resp=$(curl -sSL -H "Authorization: token $TOKEN" "$url")
sha=$(echo "$resp" | jq -r 'if (type=="object" and .sha!=null) then .sha else "" end')
sha=$(curl -sSL --fail -H "Authorization: token $TOKEN" "$url" \
| jq -r 'select(.sha != null).sha // empty')
if [ -z "$sha" ]; then
payload=$(jq -n --arg m "Add CI from skins-template" --arg c "$TEMPLATE_B64" '{message: $m, content: $c, branch: "main"}')
if [[ -z "$sha" ]]; then
msg="Add CI from skins-template"
payload=$(jq -nc \
--arg message "$msg" \
--arg content "$TEMPLATE_B64" \
'{message: $message, content: $content, branch: "main"}')
else
payload=$(jq -n --arg m "Update CI from skins-template" --arg c "$TEMPLATE_B64" --arg s "$sha" '{message: $m, content: $c, sha: $s, branch: "main"}')
msg="Update CI from skins-template"
payload=$(jq -nc \
--arg message "$msg" \
--arg content "$TEMPLATE_B64" \
--arg sha "$sha" \
'{message: $message, content: $content, sha: $sha, branch: "main"}')
fi
if curl -sSL --fail -X PUT \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "$payload" \
"$url" \
>/dev/null; then
echo "✅ $owner/$repo"
else
echo "❌ $owner/$repo" >&2
fi
curl -sSL -X PUT -H "Authorization: token $TOKEN" -H "Content-Type: application/json" -d "$payload" "$url"
done
- name: Cleanup