Skip to content

Commit e48778e

Browse files
fix: poll for provenance before deploying (#4987)
This adds a delay of up to 2 minutes for the docker image to be ready. fixes: flutter/flutter#183787 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 544ad9f commit e48778e

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

app_dart/cloudbuild_app_dart_deploy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55
# The auto-build will be skipped if no new commits since last deployment.
66

77
steps:
8+
# Step 0: Poll for the provenance
9+
- name: gcr.io/cloud-builders/gcloud
10+
entrypoint: '/bin/bash'
11+
args:
12+
- '-c'
13+
- |-
14+
echo "Waiting for provenance to be indexed by Google..."
15+
# Loop for up to 2 minutes
16+
for i in {1..12}; do
17+
if gcloud artifacts docker images describe \
18+
us-docker.pkg.dev/$PROJECT_ID/appengine/default.version-$SHORT_SHA:latest \
19+
--show-provenance > /dev/null 2>&1; then
20+
echo "Provenance is ready!"
21+
exit 0
22+
fi
23+
echo "Not ready yet (Attempt $i/12). Sleeping 10s..."
24+
sleep 10
25+
done
26+
echo "ERROR: Provenance never appeared."
27+
exit 1
28+
829
# Get recently pushed docker image and associated provenance, along with the
930
# correct docker digest url, including the hash.
1031
- name: gcr.io/cloud-builders/gcloud

auto_submit/cloudbuild_auto_submit_deploy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55
# The auto-build will be skipped if no new commits since last deployment.
66

77
steps:
8+
# Step 0: Poll for the provenance
9+
- name: gcr.io/cloud-builders/gcloud
10+
entrypoint: '/bin/bash'
11+
args:
12+
- '-c'
13+
- |-
14+
echo "Waiting for provenance to be indexed by Google..."
15+
# Loop for up to 2 minutes
16+
for i in {1..12}; do
17+
if gcloud artifacts docker images describe \
18+
us-docker.pkg.dev/$PROJECT_ID/appengine/auto-submit.version-$SHORT_SHA:latest \
19+
--show-provenance > /dev/null 2>&1; then
20+
echo "Provenance is ready!"
21+
exit 0
22+
fi
23+
echo "Not ready yet (Attempt $i/12). Sleeping 10s..."
24+
sleep 10
25+
done
26+
echo "ERROR: Provenance never appeared."
27+
exit 1
28+
829
# Get recently pushed docker image and associated provenance, along with the
930
# correct docker digest url, including the hash.
1031
- name: gcr.io/cloud-builders/gcloud

0 commit comments

Comments
 (0)