Skip to content

πŸ™Œ OpenHands: AI-Driven Development

ci: wait for the docker build before retagging images (#15213)

Joe Lavertyd3b43ff34c53
diff --git a/.github/workflows/bump-chart.yml b/.github/workflows/bump-chart.yml
index 142d791815..55db9b335e 100644
--- a/.github/workflows/bump-chart.yml
+++ b/.github/workflows/bump-chart.yml
@@ -1,17 +1,24 @@
# Opens a PR in OpenHands/OpenHands-Cloud pointing the openhands chart's
-# image.tag at the enterprise-server image that was just tagged. tag-image.yml
-# retags the sha-built image with the tag name (type=ref,event=tag)
-# concurrently, so the image tag matches the git tag verbatim β€” no prefix
-# stripping needed.
+# image.tag at the enterprise-server image for this tag. Triggered by
+# "Tag Docker images" completing (rather than the tag push itself) so the
+# chart PR only opens once the image tag actually resolves.
name: Bump chart image tag
on:
- push:
- tags:
- - 'cloud-[0-9]+.[0-9]+.[0-9]+'
+ workflow_run:
+ workflows: ["Tag Docker images"]
+ types: [completed]
jobs:
bump-chart:
+ # "Tag Docker images" only runs on tag pushes, and workflow_run's
+ # head_branch carries the tag name for tag-triggered runs. Match the
+ # cloud line here rather than with a trigger-level `branches:` glob β€”
+ # whether that filter applies to tag-named head_branch values is
+ # undocumented, and a non-match would silently skip the chart bump.
+ if: >-
+ github.event.workflow_run.conclusion == 'success' &&
+ startsWith(github.event.workflow_run.head_branch, 'cloud-')
# secrets: inherit forwards the org secrets RELEASE_APP_ID /
# RELEASE_APP_PRIVATE_KEY that the reusable workflow needs.
secrets: inherit
@@ -21,4 +28,4 @@ jobs:
chart_file: charts/openhands/values.yaml
metadata_file: charts/openhands/Chart.yaml
metadata_path: .appVersion
- tag: ${{ github.ref_name }}
+ tag: ${{ github.event.workflow_run.head_branch }}
diff --git a/.github/workflows/tag-image.yml b/.github/workflows/tag-image.yml
index 2763419615..119c3d1d7c 100644
--- a/.github/workflows/tag-image.yml
+++ b/.github/workflows/tag-image.yml
@@ -3,6 +3,12 @@
# (tagged `sha-<full>`) and adds the tag name as an alias for the same manifest.
# Semver tags (X.Y.Z) also get X.Y, X, and latest aliases.
# No rebuild β€” pure registry-side retag via `docker buildx imagetools create`.
+#
+# Release-please pushes the release tag a minute or so after the release PR
+# merges, while the Docker workflow is still building images for that same
+# commit β€” so wait-for-build blocks (a few minutes) until that run completes
+# before retagging. Tags pushed to already-built commits pass straight
+# through: watching a completed run returns immediately.
name: Tag Docker images
on:
@@ -11,7 +17,38 @@ on:
- "*"
jobs:
+ wait-for-build:
+ runs-on: ubuntu-22.04
+ timeout-minutes: 60
+ permissions:
+ actions: read
+ steps:
+ - name: Wait for the Docker workflow run on this commit
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ COMMIT_SHA: ${{ github.sha }}
+ shell: bash
+ run: |
+ # The Docker run is registered by the branch push, which normally
+ # lands a minute or more before the tag does β€” but retry briefly in
+ # case this tag arrived first.
+ run_id=""
+ for _ in $(seq 1 10); do
+ run_id=$(gh run list --repo "$GITHUB_REPOSITORY" \
+ --workflow ghcr-build.yml --commit "$COMMIT_SHA" \
+ --limit 1 --json databaseId --jq '.[0].databaseId // empty')
+ [[ -n "$run_id" ]] && break
+ sleep 30
+ done
+ if [[ -z "$run_id" ]]; then
+ echo "::error::No Docker workflow run found for $COMMIT_SHA β€” images were never built for this commit."
+ exit 1
+ fi
+ echo "Waiting on Docker run $run_id for $COMMIT_SHA."
+ gh run watch --repo "$GITHUB_REPOSITORY" "$run_id" --interval 30 --exit-status
+
retag:
+ needs: wait-for-build
runs-on: ubuntu-22.04
permissions:
packages: write