From b89156fd5bb4ab1da5d960d18ddd80a25b366753 Mon Sep 17 00:00:00 2001 From: Arlind Date: Mon, 9 Jun 2025 09:59:44 +0200 Subject: [PATCH] Update .gitea/workflows/deploy-ci.yaml --- .gitea/workflows/deploy-ci.yaml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/deploy-ci.yaml b/.gitea/workflows/deploy-ci.yaml index 88f7740..f805073 100644 --- a/.gitea/workflows/deploy-ci.yaml +++ b/.gitea/workflows/deploy-ci.yaml @@ -19,6 +19,7 @@ jobs: - name: Fetch CI template via Gitea API shell: bash run: | + set -eo pipefail 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) @@ -27,6 +28,7 @@ jobs: - name: Fetch valid user repositories shell: bash run: | + set -eo pipefail page=1 per_page=50 valid_repos_file=$(mktemp) @@ -74,24 +76,34 @@ jobs: echo "VALID_REPOS_FILE=$valid_repos_file" >> $GITHUB_ENV - - name: Update CI via Gitea API + - name: Update CI via Gitea API (with debug) shell: bash run: | - set -eo pipefail + set -euxo pipefail mapfile -t repos < "$VALID_REPOS_FILE" for repo_full in "${repos[@]}"; do owner=${repo_full%%/*} repo=${repo_full##*/} api="$GITEA_API/repos/$owner/$repo" + echo "Processing $owner/$repo" default_branch=$(curl -sSL --fail -H "Authorization: token $TOKEN" \ "$api" | jq -r '.default_branch') + echo "Default branch: $default_branch" latest_tag=$(curl -sSL --fail -H "Authorization: token $TOKEN" \ "$api/tags" | jq -r '.[0].name // empty') - if [[ "$latest_tag" != "v1.0.0" ]]; then - curl -sSL -X DELETE -H "Authorization: token $TOKEN" \ - "$api/git/refs/tags/$latest_tag" || true + echo "Latest tag: '$latest_tag'" + + if [[ -z "$latest_tag" ]]; then + echo "No tags found, skipping deletion" + elif [[ "$latest_tag" == "v1.0.0" ]]; then + echo "Skipping deletion for protected tag v1.0.0" + else + echo "Deleting tag '$latest_tag'" + delete_response=$(curl -sSL -X DELETE -H "Authorization: token $TOKEN" \ + "$api/git/refs/tags/$latest_tag" -w "%{http_code}" -o /dev/null) || delete_response=error + echo "Delete response code: $delete_response" fi url="$api/contents/$TEMPLATE_PATH"