From 8cc5c0266a9ebd5f51776cfc8688efbde313563f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Untersch=C3=BCtz?= Date: Wed, 25 Nov 2026 19:59:29 +0100 Subject: [PATCH] fix(release): publish the Helm chart only once the images exist The release job finished about 20 minutes before the ci workflow had pushed the tag's images. Clusters following the chart repository then rolled out a release whose image did not exist yet: the migrate hook sat in ImagePullBackOff until its deadline and the upgrade failed (0.2.1, 0.3.0 and 0.4.0 on app.uptimesebi.net). Wait up to 90 minutes for the API, checker and status page images of the tag before publishing the chart. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/release.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index da29422..c8270fb 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -83,6 +83,41 @@ jobs: curl -fsS -o /dev/null -X POST -H "Authorization: token $TOKEN" \ -F "attachment=@$f" "$api/releases/$id/assets?name=$(basename "$f")" done + # The ci workflow builds the images of this tag after lint and tests, + # which takes longer than this job. A chart published before them makes + # clusters that follow the chart repository roll out a release whose + # images do not exist yet (ImagePullBackOff in the migrate hook). + - name: Wait for the images + env: + PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }} + run: | + set -eu + if [ -z "$PACKAGE_TOKEN" ]; then + echo "::warning::PACKAGE_TOKEN is not set; not waiting for the images." + exit 0 + fi + host="${GITHUB_SERVER_URL#*://}" + owner="$(printf '%s' "${GITHUB_REPOSITORY%/*}" | tr 'A-Z' 'a-z')" + tag="${GITHUB_REF_NAME#v}" + accept="application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json" + deadline=$(( $(date +%s) + 90 * 60 )) + for repo in uptimesebi uptimesebi-checker uptimesebi-statuspage; do + until + token="$(curl -fsS --user "$GITHUB_ACTOR:$PACKAGE_TOKEN" \ + "$GITHUB_SERVER_URL/v2/token?service=container_registry&scope=repository:$owner/$repo:pull" \ + | sed -n 's/.*"token":"\([^"]*\)".*/\1/p')" + curl -fsS -o /dev/null -I -H "Authorization: Bearer $token" -H "Accept: $accept" \ + "$GITHUB_SERVER_URL/v2/$owner/$repo/manifests/$tag" + do + if [ "$(date +%s)" -ge "$deadline" ]; then + echo "::error::$host/$owner/$repo:$tag did not appear within 90 minutes; the chart is not published." + exit 1 + fi + echo "waiting for $host/$owner/$repo:$tag" + sleep 30 + done + echo "$host/$owner/$repo:$tag is there" + done # helm repo add uptimesebi /api/packages//helm - name: Publish Helm chart env: -- 2.54.1