diff --git a/.github/workflows/publish-charts.yml b/.github/workflows/publish-charts.yml index a0cbc8dc1..3d58715b1 100644 --- a/.github/workflows/publish-charts.yml +++ b/.github/workflows/publish-charts.yml @@ -18,6 +18,24 @@ jobs: egress-policy: audit - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - name: Verify container image exists + run: | + VERSION=${GITHUB_REF#refs/tags/} + ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) + IMAGE="ghcr.io/${ORG_NAME}/ratify-gatekeeper-provider:${VERSION}" + echo "Checking if image exists: ${IMAGE}" + MAX_RETRIES=30 + RETRY_INTERVAL=60 + for i in $(seq 1 $MAX_RETRIES); do + if docker buildx imagetools inspect "${IMAGE}" > /dev/null 2>&1; then + echo "Image ${IMAGE} found!" + exit 0 + fi + echo "Attempt ${i}/${MAX_RETRIES}: Image not found yet, retrying in ${RETRY_INTERVAL}s..." + sleep $RETRY_INTERVAL + done + echo "ERROR: Image ${IMAGE} not found after ${MAX_RETRIES} attempts" + exit 1 - name: Publish Helm charts uses: stefanprodan/helm-gh-pages@0ad2bb377311d61ac04ad9eb6f252fb68e207260 # v1.7.0 with: diff --git a/.github/workflows/publish-dev-assets.yml b/.github/workflows/publish-dev-assets.yml index 149ce9405..26292f2f4 100644 --- a/.github/workflows/publish-dev-assets.yml +++ b/.github/workflows/publish-dev-assets.yml @@ -113,6 +113,33 @@ jobs: sed -i '/^ repository:/c\ repository: ghcr.io/ratify-project/ratify-dev' charts/ratify/values.yaml sed -i '/^ crdRepository:/c\ crdRepository: ghcr.io/ratify-project/ratify-crds-dev' charts/ratify/values.yaml sed -i '/^ tag:/c\ tag: ${{ steps.prepare.outputs.version }}' charts/ratify/values.yaml + - name: Verify container images exist + run: | + IMAGES=( + "${{ steps.prepare.outputs.crdref }}:${{ steps.prepare.outputs.version }}" + "${{ steps.prepare.outputs.baseref }}:${{ steps.prepare.outputs.version }}" + "${{ steps.prepare.outputs.ref }}:${{ steps.prepare.outputs.version }}" + ) + MAX_ATTEMPTS=5 + BASE_SLEEP_SECONDS=5 + for IMAGE in "${IMAGES[@]}"; do + echo "Checking if image exists: ${IMAGE}" + for ATTEMPT in $(seq 1 "${MAX_ATTEMPTS}"); do + if docker buildx imagetools inspect "${IMAGE}" > /dev/null 2>&1; then + echo "Image ${IMAGE} found!" + break + fi + + if [ "${ATTEMPT}" -eq "${MAX_ATTEMPTS}" ]; then + echo "ERROR: Image ${IMAGE} not found after ${MAX_ATTEMPTS} attempts!" + exit 1 + fi + + SLEEP_SECONDS=$((BASE_SLEEP_SECONDS * ATTEMPT)) + echo "Image ${IMAGE} not available yet (attempt ${ATTEMPT}/${MAX_ATTEMPTS}); retrying in ${SLEEP_SECONDS}s..." + sleep "${SLEEP_SECONDS}" + done + done - name: helm package run: | helm package ./charts/ratify --version ${{ steps.prepare.outputs.semversion }}