From d4ba40feffb81adbe1c21527f36248fb5b02d9d0 Mon Sep 17 00:00:00 2001 From: Andrew Bolyachevets Date: Thu, 24 Oct 2024 15:38:41 -0700 Subject: [PATCH] if its the first deployment, there will be no previous revision (#186) --- .github/actions/backend-deploy/files/cloudbuild.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/actions/backend-deploy/files/cloudbuild.yaml b/.github/actions/backend-deploy/files/cloudbuild.yaml index 515edbf3..e1509d96 100644 --- a/.github/actions/backend-deploy/files/cloudbuild.yaml +++ b/.github/actions/backend-deploy/files/cloudbuild.yaml @@ -231,11 +231,12 @@ steps: echo "$DEPLOYED_REVISION" > /workspace/deployed_revision.txt echo "Deployed revision: $DEPLOYED_REVISION" - # Update traffic to 0 for the new revision and wait for the new revision to be ready - gcloud run services update-traffic "${_APP_NAME}-${_DEPLOYMENT_ENV}" \ - --region="${_REGION}" \ - --project="$PROJECT_ID" \ - --to-revisions="$PREVIOUS_REVISION=100" + if [[ -n "$PREVIOUS_REVISION" ]]; then + # Update traffic to 0 for the new revision and wait for the new revision to be ready + gcloud run services update-traffic "${_APP_NAME}-${_DEPLOYMENT_ENV}" \ + --region="${_REGION}" \ + --project="$PROJECT_ID" \ + --to-revisions="$PREVIOUS_REVISION=100" # Step 3: Trigger database migration job (if applicable) - name: 'gcr.io/cloud-builders/gcloud'