| # Provide instructions for google Cloud Build to auto-build flutter | |
| # auto submit to flutter-dashboard project. Auto-build will be triggered | |
| # by daily schedule on `main` branch. | |
| # | |
| # The auto-build will be skipped if no new commits since last deployment. | |
| steps: | |
| # Step 0: Poll for the provenance | |
| - name: gcr.io/cloud-builders/gcloud | |
| entrypoint: '/bin/bash' | |
| args: | |
| - '-c' | |
| - |- | |
| echo "Waiting for provenance to be indexed by Google..." | |
| # Loop for up to 2 minutes | |
| for i in {1..12}; do | |
| if gcloud artifacts docker images describe \ | |
| us-docker.pkg.dev/$PROJECT_ID/appengine/auto-submit.version-$SHORT_SHA:latest \ | |
| --show-provenance > /dev/null 2>&1; then | |
| echo "Provenance is ready!" | |
| exit 0 | |
| fi | |
| echo "Not ready yet (Attempt $i/12). Sleeping 10s..." | |
| sleep 10 | |
| done | |
| echo "ERROR: Provenance never appeared." | |
| exit 1 | |
| # Get recently pushed docker image and associated provenance, along with the | |
| # correct docker digest url, including the hash. | |
| - name: gcr.io/cloud-builders/gcloud | |
| entrypoint: '/bin/bash' | |
| args: | |
| - '-c' | |
| - |- | |
| cloud_build/get_docker_image_provenance.sh \ | |
| us-docker.pkg.dev/$PROJECT_ID/appengine/auto-submit.version-$SHORT_SHA:latest \ | |
| unverified_provenance.json | |
| # Verify provenance is valid before proceeding with deployment. | |
| - name: 'golang:1.26-bookworm' | |
| entrypoint: '/bin/bash' | |
| args: | |
| - '-c' | |
| - |- | |
| cloud_build/verify_provenance.sh unverified_provenance.json | |
| # Deploy a new version to google cloud. | |
| - name: gcr.io/cloud-builders/gcloud | |
| entrypoint: '/bin/bash' | |
| args: | |
| - '-c' | |
| - |- | |
| gcloud config set project $PROJECT_ID | |
| latest_version=$(gcloud app versions list --hide-no-traffic --format 'value(version.id)') | |
| if [ "$latest_version" = "version-$SHORT_SHA" ]; then | |
| echo "No updates since last deployment." | |
| else | |
| bash cloud_build/deploy_auto_submit.sh $PROJECT_ID $SHORT_SHA | |
| fi | |
| timeout: 1200s |