@@ -701,6 +701,38 @@ jobs:
701701 path : lambdaImage.tar.gz
702702 if-no-files-found : error
703703
704+ # Building races ahead of the test verdict; SHIPPING is what gates on it.
705+ # A tag's commit already ran ci when it landed on main — this waits for
706+ # that verdict and fails closed if it is missing or red.
707+ ci-green :
708+ name : ci green gate
709+ if : startsWith(github.ref, 'refs/tags/')
710+ runs-on : ubuntu-24.04
711+ timeout-minutes : 40
712+ permissions :
713+ actions : read
714+ contents : read
715+ steps :
716+ - name : wait for the commit's ci verdict
717+ env :
718+ GH_TOKEN : ${{ github.token }}
719+ run : |
720+ set -euo pipefail
721+ for _ in $(seq 1 40); do
722+ run="$(gh api "/repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$GITHUB_SHA&per_page=1" \
723+ --jq '"\(.workflow_runs[0].status // "none") \(.workflow_runs[0].conclusion // "")"')"
724+ status="${run%% *}"; conclusion="${run#* }"
725+ [ "$conclusion" = "success" ] && exit 0
726+ if [ "$status" = "completed" ]; then
727+ echo "ci for $GITHUB_SHA concluded: ${conclusion:-none}" >&2
728+ exit 1
729+ fi
730+ echo "ci for $GITHUB_SHA: $status — waiting"
731+ sleep 60
732+ done
733+ echo "timed out waiting for the ci verdict" >&2
734+ exit 1
735+
704736 promote :
705737 name : promote prebuilt targets
706738 needs : build-id
@@ -797,11 +829,15 @@ jobs:
797829
798830 image :
799831 name : ghcr image
800- needs : build-id
801- # Tags always run (they push); otherwise only when no prebuilt artifact
802- # exists yet — a non-tag run with a prebuilt would skip every step and
803- # burn a runner fetching an artifact it discards.
804- if : startsWith(github.ref, 'refs/tags/') || needs.build-id.outputs.image_docker == ''
832+ needs : [build-id, ci-green]
833+ # Tags always run (they push) but only with a green ci verdict for the
834+ # commit; otherwise only when no prebuilt artifact exists yet — a
835+ # non-tag run with a prebuilt would skip every step and burn a runner
836+ # fetching an artifact it discards.
837+ if : >-
838+ !cancelled() && needs.build-id.result == 'success' &&
839+ ((startsWith(github.ref, 'refs/tags/') && needs.ci-green.result == 'success') ||
840+ (!startsWith(github.ref, 'refs/tags/') && needs.build-id.outputs.image_docker == ''))
805841 runs-on : ubuntu-24.04
806842 permissions :
807843 contents : read
@@ -875,9 +911,13 @@ jobs:
875911
876912 lambda-image :
877913 name : ECR lambda image
878- needs : build-id
879- # Same gate as the ghcr image: tags push, non-tag runs only build.
880- if : startsWith(github.ref, 'refs/tags/') || needs.build-id.outputs.image_lambda == ''
914+ needs : [build-id, ci-green]
915+ # Same gate as the ghcr image: tags push (green ci only), non-tag runs
916+ # only build.
917+ if : >-
918+ !cancelled() && needs.build-id.result == 'success' &&
919+ ((startsWith(github.ref, 'refs/tags/') && needs.ci-green.result == 'success') ||
920+ (!startsWith(github.ref, 'refs/tags/') && needs.build-id.outputs.image_lambda == ''))
881921 runs-on : ubuntu-24.04-arm
882922 permissions :
883923 contents : read
@@ -980,11 +1020,12 @@ jobs:
9801020
9811021 napi-publish :
9821022 name : publish @dcl/abgen-node
983- needs : [build-id, napi]
1023+ needs : [build-id, napi, ci-green ]
9841024 runs-on : ubuntu-24.04
9851025 if : >-
9861026 !cancelled() &&
9871027 startsWith(github.ref, 'refs/tags/v') && inputs.dry_run != true &&
1028+ needs.ci-green.result == 'success' &&
9881029 (needs.napi.result == 'success' ||
9891030 (needs.napi.result == 'skipped' && needs.build-id.outputs.napi_promote == 'true'))
9901031 permissions :
@@ -1046,11 +1087,12 @@ jobs:
10461087 npm publish --access public
10471088
10481089 publish :
1049- needs : [build, promote]
1090+ needs : [build, promote, ci-green ]
10501091 runs-on : ubuntu-24.04
10511092 if : >-
10521093 !cancelled() &&
10531094 startsWith(github.ref, 'refs/tags/v') && inputs.dry_run != true &&
1095+ needs.ci-green.result == 'success' &&
10541096 needs.build.result != 'failure' && needs.build.result != 'cancelled' &&
10551097 needs.promote.result != 'failure' && needs.promote.result != 'cancelled'
10561098 permissions :
0 commit comments