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
This commit is contained in:
Deirdre Connolly 2020-06-21 04:39:47 -04:00 committed by GitHub
parent 6324ad8828
commit 2bdd07c1bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 12 deletions

View File

@ -1,4 +1,4 @@
name: CI name: CD
on: on:
push: push:
@ -29,7 +29,8 @@ jobs:
echo "::set-env name=SHA7::$(git rev-parse --short=7 $GITHUB_SHA)" echo "::set-env name=SHA7::$(git rev-parse --short=7 $GITHUB_SHA)"
# Setup gcloud CLI # 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: with:
version: '295.0.0' version: '295.0.0'
project_id: ${{ env.PROJECT_ID }} project_id: ${{ env.PROJECT_ID }}
@ -72,19 +73,28 @@ jobs:
# --source-ranges 0.0.0.0/0 \ # --source-ranges 0.0.0.0/0 \
# --description="Allow incoming Zcash traffic from anywhere" \ # --description="Allow incoming Zcash traffic from anywhere" \
# Deploy managed instance group using the new instance template # Check if our destination instance group exists already
# - name: Deploy managed instance group - name: Check if instance group exists
# run: | id: does-group-exist
# gcloud compute instance-groups managed create \ continue-on-error: true
# "zebrad-$SHORT_BRANCH_NAME-$SHA7" \ run: |
# --template "zebrad-$SHORT_BRANCH_NAME-$SHA7" \ gcloud compute instance-groups list | grep "zebrad-$SHORT_BRANCH_NAME"
# --health-check zebrad-tracing-filter \
# --initial-delay 30 \ # Deploy new managed instance group using the new instance template
# --region us-central1 \ - name: Create managed instance group
# --size 2 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 # Rolls out update to existing group using the new instance template
- name: Update managed instance group - name: Update managed instance group
if: steps.does-group-exist.outcome == 'success'
run: | run: |
gcloud compute instance-groups managed rolling-action start-update \ gcloud compute instance-groups managed rolling-action start-update \
"zebrad-$SHORT_BRANCH_NAME" \ "zebrad-$SHORT_BRANCH_NAME" \