From 2bdd07c1bccf90d1ec8eba2c4c71ba741ac32e48 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Sun, 21 Jun 2020 04:39:47 -0400 Subject: [PATCH] Create instance group if it doesn't exist, update it if it does (#513) * Deploy instance group if it doesn't exist, update it if it does * Rename push.yml to cd.yml * Rename some CD steps --- .github/workflows/{push.yml => cd.yml} | 34 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) rename .github/workflows/{push.yml => cd.yml} (75%) diff --git a/.github/workflows/push.yml b/.github/workflows/cd.yml similarity index 75% rename from .github/workflows/push.yml rename to .github/workflows/cd.yml index 926a60f7a..72dc2f413 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/cd.yml @@ -1,4 +1,4 @@ -name: CI +name: CD on: push: @@ -29,7 +29,8 @@ jobs: echo "::set-env name=SHA7::$(git rev-parse --short=7 $GITHUB_SHA)" # Setup gcloud CLI - - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + - name: Set up gcloud Cloud SDK environment + uses: GoogleCloudPlatform/github-actions/setup-gcloud@master with: version: '295.0.0' project_id: ${{ env.PROJECT_ID }} @@ -72,19 +73,28 @@ jobs: # --source-ranges 0.0.0.0/0 \ # --description="Allow incoming Zcash traffic from anywhere" \ - # Deploy managed instance group using the new instance template - # - name: Deploy managed instance group - # run: | - # gcloud compute instance-groups managed create \ - # "zebrad-$SHORT_BRANCH_NAME-$SHA7" \ - # --template "zebrad-$SHORT_BRANCH_NAME-$SHA7" \ - # --health-check zebrad-tracing-filter \ - # --initial-delay 30 \ - # --region us-central1 \ - # --size 2 + # Check if our destination instance group exists already + - name: Check if instance group exists + id: does-group-exist + continue-on-error: true + run: | + gcloud compute instance-groups list | grep "zebrad-$SHORT_BRANCH_NAME" + + # Deploy new managed instance group using the new instance template + - name: Create managed instance group + if: steps.does-group-exist.outcome == 'failure' + run: | + gcloud compute instance-groups managed create \ + "zebrad-$SHORT_BRANCH_NAME" \ + --template "zebrad-$SHORT_BRANCH_NAME-$SHA7" \ + --health-check zebrad-tracing-filter \ + --initial-delay 30 \ + --region us-central1 \ + --size 2 # Rolls out update to existing group using the new instance template - name: Update managed instance group + if: steps.does-group-exist.outcome == 'success' run: | gcloud compute instance-groups managed rolling-action start-update \ "zebrad-$SHORT_BRANCH_NAME" \