fix(release): publish the Helm chart only once the images exist
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 9m11s
ci / lint (pull_request) Successful in 12m40s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 9m11s
ci / lint (pull_request) Successful in 12m40s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
87ab065e24
commit
8cc5c0266a
1 file changed
+35
@@ -83,6 +83,41 @@ jobs:
|
|||||||
curl -fsS -o /dev/null -X POST -H "Authorization: token $TOKEN" \
|
curl -fsS -o /dev/null -X POST -H "Authorization: token $TOKEN" \
|
||||||
-F "attachment=@$f" "$api/releases/$id/assets?name=$(basename "$f")"
|
-F "attachment=@$f" "$api/releases/$id/assets?name=$(basename "$f")"
|
||||||
done
|
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 <server>/api/packages/<owner>/helm
|
# helm repo add uptimesebi <server>/api/packages/<owner>/helm
|
||||||
- name: Publish Helm chart
|
- name: Publish Helm chart
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in new issue
Block a user