File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,30 @@ jobs:
100100 project_id : ${{ env.GCP_PROJECT_ID }}
101101 version : " >= 416.0.0"
102102
103+ - name : Wait for Cloud Run deployment of current commit
104+ if : steps.config.outputs.enabled == 'true'
105+ run : |
106+ set -euo pipefail
107+
108+ target_sha="${GITHUB_SHA}"
109+ deadline=$((SECONDS + 1800))
110+
111+ while true; do
112+ 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)"
113+ if [ -n "${deployed_sha}" ] && [ "${deployed_sha}" = "${target_sha}" ]; then
114+ echo "Cloud Run service ${CLOUD_RUN_SERVICE} is on commit ${deployed_sha}."
115+ break
116+ fi
117+
118+ if [ "${SECONDS}" -ge "${deadline}" ]; then
119+ echo "Timed out waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}" >&2
120+ exit 1
121+ fi
122+
123+ echo "Waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}" >&2
124+ sleep 10
125+ done
126+
103127 - name : Sync Cloud Run environment
104128 if : steps.config.outputs.enabled == 'true'
105129 run : |
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ grep -Fq 'permissions:' "$workflow_file"
1010grep -Fq ' id-token: write' " $workflow_file "
1111grep -Fq ' workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}' " $workflow_file "
1212grep -Fq ' service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}' " $workflow_file "
13+ grep -Fq ' Wait for Cloud Run deployment of current commit' " $workflow_file "
14+ grep -Fq ' target_sha="${GITHUB_SHA}"' " $workflow_file "
15+ grep -Fq " gcloud run services describe \"\$ {CLOUD_RUN_SERVICE}\" --region \"\$ {CLOUD_RUN_REGION}\" --format='value(spec.template.metadata.labels.commit-sha)'" " $workflow_file "
16+ grep -Fq ' Timed out waiting for Cloud Run service ${CLOUD_RUN_SERVICE} to deploy commit ${target_sha}. Last seen commit: ${deployed_sha:-<none>}' " $workflow_file "
1317grep -Fq ' ENABLE_GITHUB_ENV_SYNC: ${{ vars.ENABLE_GITHUB_ENV_SYNC }}' " $workflow_file "
1418grep -Fq ' CLOUD_RUN_REGION: ${{ vars.CLOUD_RUN_REGION }}' " $workflow_file "
1519grep -Fq ' CLOUD_RUN_SERVICE: ${{ vars.CLOUD_RUN_SERVICE }}' " $workflow_file "
You can’t perform that action at this time.
0 commit comments