Quellcode durchsuchen

fix: improve release creation handling and add retry logic for visibility

TheWildJames vor 3 Monaten
Ursprung
Commit
c26883ba30
1 geänderte Dateien mit 15 neuen und 1 gelöschten Zeilen
  1. 15 1
      .github/actions/cache-save/action.yml

+ 15 - 1
.github/actions/cache-save/action.yml

@@ -46,8 +46,11 @@ runs:
       shell: bash
       env:
         GITHUB_TOKEN: ${{ inputs.github_token }}
+        GH_TOKEN: ${{ inputs.github_token }}
         TARGET_REPO: "${{ github.repository }}"
       run: |
+        set -euo pipefail
+
         # Validate and parse inputs
         PATHS_INPUT="${{ inputs.cache_paths }}"
         KEYS_INPUT="${{ inputs.cache_keys }}"
@@ -84,6 +87,7 @@ runs:
         # Helper function to handle release creation
         ensure_release() {
           local tag_name="$1"
+          local attempts=0
           
           if gh release view "$tag_name" --repo "$TARGET_REPO" >/dev/null 2>&1; then
             echo "Release '$tag_name' already exists. Ready for upload."
@@ -97,7 +101,17 @@ runs:
             --title "Build Cache" \
             --notes "Automated storage for build assets" \
             --latest=false \
-            --repo "$TARGET_REPO" || true
+            --repo "$TARGET_REPO"
+
+          until gh release view "$tag_name" --repo "$TARGET_REPO" >/dev/null 2>&1; do
+            attempts=$((attempts + 1))
+            if [ "$attempts" -ge 5 ]; then
+              echo "::error::Release '$tag_name' is still not visible after creation."
+              return 1
+            fi
+            sleep 3
+          done
+
           gh release edit "$tag_name" --latest=false --repo "$TARGET_REPO" >/dev/null 2>&1 || true
         }