@@ -101,6 +101,30 @@ jobs:
101101 project_id : ${{ env.GCP_PROJECT_ID }}
102102 version : " >= 416.0.0"
103103
104+ - name : Wait for Cloud Run deployment of current commit
105+ if : steps.config.outputs.enabled == 'true'
106+ run : |
107+ set -euo pipefail
108+
109+ target_sha="${GITHUB_SHA}"
110+ deadline=$((SECONDS + 1800))
111+
112+ while true; do
113+ deployed_sha="$(gcloud run services describe "${CLOUD_RUN_SERVICE}" --region "${CLOUD_RUN_REGION}" --format='value(spec.template.metadata.labels.commit-sha)' 2>/dev/null || true)"
114+ if [ -n "${deployed_sha}" ] && [ "${deployed_sha}" = "${target_sha}" ]; then
115+ echo "Cloud Run service ${CLOUD_RUN_SERVICE} is on commit ${deployed_sha}."
116+ break
117+ fi
118+
119+ if [ "${SECONDS}" -ge "${deadline}" ]; then
120+ echo "Timed out waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}" >&2
121+ exit 1
122+ fi
123+
124+ echo "Waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}" >&2
125+ sleep 10
126+ done
127+
104128 - name : Sync Cloud Run environment
105129 if : steps.config.outputs.enabled == 'true'
106130 run : |
@@ -249,6 +273,30 @@ jobs:
249273 project_id : ${{ env.GCP_PROJECT_ID }}
250274 version : " >= 416.0.0"
251275
276+ - name : Wait for Cloud Run deployment of current commit
277+ if : steps.config.outputs.enabled == 'true'
278+ run : |
279+ set -euo pipefail
280+
281+ target_sha="${GITHUB_SHA}"
282+ deadline=$((SECONDS + 1800))
283+
284+ while true; do
285+ deployed_sha="$(gcloud run services describe "${CLOUD_RUN_SERVICE}" --region "${CLOUD_RUN_REGION}" --format='value(spec.template.metadata.labels.commit-sha)' 2>/dev/null || true)"
286+ if [ -n "${deployed_sha}" ] && [ "${deployed_sha}" = "${target_sha}" ]; then
287+ echo "Cloud Run service ${CLOUD_RUN_SERVICE} is on commit ${deployed_sha}."
288+ break
289+ fi
290+
291+ if [ "${SECONDS}" -ge "${deadline}" ]; then
292+ echo "Timed out waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}" >&2
293+ exit 1
294+ fi
295+
296+ echo "Waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}" >&2
297+ sleep 10
298+ done
299+
252300 - name : Sync Cloud Run environment
253301 if : steps.config.outputs.enabled == 'true'
254302 run : |
0 commit comments