From 244a55fc0e734fe75b99e9895bbe34d438c53eb3 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Thu, 4 Mar 2021 12:30:25 -0800 Subject: [PATCH 1/4] Add manual deploy workflow for zcashd images --- .github/workflows/zcashd-cd.yml | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/zcashd-cd.yml diff --git a/.github/workflows/zcashd-cd.yml b/.github/workflows/zcashd-cd.yml new file mode 100644 index 00000000000..d652197b3d9 --- /dev/null +++ b/.github/workflows/zcashd-cd.yml @@ -0,0 +1,77 @@ +name: Zcashd Manual Deploy + +on: + workflow_dispatch: + inputs: + network: + default: 'testnet' + size: + default: 10 + +env: + PROJECT_ID: zealous-zebra + REGION: us-east1 + ZONE: us-east1-b + +jobs: + + deploy: + name: Deploy mainnet nodes + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + + - name: Set project and image names + run: | + BRANCH_NAME=$(expr $GITHUB_REF : '.*/\(.*\)') && \ + BRANCH_NAME=${BRANCH_NAME,,} && \ + REPOSITORY=${GITHUB_REPOSITORY,,} && \ + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV && \ + echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV && \ + echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV + + # Setup gcloud CLI + - name: Set up gcloud SDK environment + uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + with: + version: '295.0.0' + project_id: ${{ env.PROJECT_ID }} + service_account_key: ${{ secrets.GCLOUD_AUTH }} + + # Create instance template from container image + - name: Create instance template + run: | + gcloud compute instance-templates create-with-container "zcashd-$BRANCH_NAME-$SHORT_SHA" \ + --container-image "electriccoinco/zcashd" \ + --container-env ZCASHD_NETWORK="${{ github.event.inputs.network }}" \ + --machine-type n2d-standard-4 \ + --service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \ + --scopes cloud-platform \ + --tags zcashd \ + + # 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 "zcashd-$BRANCH_NAME-${{ github.event.inputs.network }}"\ \ "$REGION" + + # 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 \ + "zcashd-$BRANCH_NAME-${{ github.event.inputs.network }}" \ + --template "zcashd-$BRANCH_NAME-$SHORT_SHA" \ + --region "$REGION" \ + --size "${{ github.event.inputs.size }}" + + # 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 \ + "zcashd-$BRANCH_NAME-${{ github.event.inputs.network }}" \ + --version template="zcashd-$BRANCH_NAME-$SHORT_SHA" \ + --region "$REGION" From 7a72f2ed98b5594c373fe76bc4efac832b1181f3 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Fri, 5 Mar 2021 11:37:54 -0800 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Deirdre Connolly --- .github/workflows/zcashd-cd.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/zcashd-cd.yml b/.github/workflows/zcashd-cd.yml index d652197b3d9..b1236dffb9f 100644 --- a/.github/workflows/zcashd-cd.yml +++ b/.github/workflows/zcashd-cd.yml @@ -10,8 +10,8 @@ on: env: PROJECT_ID: zealous-zebra - REGION: us-east1 - ZONE: us-east1-b + REGION: us-central1 + ZONE: us-central1-c jobs: @@ -26,10 +26,8 @@ jobs: run: | BRANCH_NAME=$(expr $GITHUB_REF : '.*/\(.*\)') && \ BRANCH_NAME=${BRANCH_NAME,,} && \ - REPOSITORY=${GITHUB_REPOSITORY,,} && \ echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV && \ echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV && \ - echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV # Setup gcloud CLI - name: Set up gcloud SDK environment @@ -43,6 +41,7 @@ jobs: - name: Create instance template run: | gcloud compute instance-templates create-with-container "zcashd-$BRANCH_NAME-$SHORT_SHA" \ + --boot-disk-size 100GB \ --container-image "electriccoinco/zcashd" \ --container-env ZCASHD_NETWORK="${{ github.event.inputs.network }}" \ --machine-type n2d-standard-4 \ From bbb6c3eaa2697dd8d256adc6cc1174c5229b9b87 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Fri, 5 Mar 2021 11:42:26 -0800 Subject: [PATCH 3/4] fix bash syntax error --- .github/workflows/zcashd-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/zcashd-cd.yml b/.github/workflows/zcashd-cd.yml index b1236dffb9f..b5748ac2925 100644 --- a/.github/workflows/zcashd-cd.yml +++ b/.github/workflows/zcashd-cd.yml @@ -27,7 +27,7 @@ jobs: BRANCH_NAME=$(expr $GITHUB_REF : '.*/\(.*\)') && \ BRANCH_NAME=${BRANCH_NAME,,} && \ echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV && \ - echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV && \ + echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV # Setup gcloud CLI - name: Set up gcloud SDK environment From 1160ac913a269247288ae5f9e5593770e71cc0fe Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Fri, 5 Mar 2021 12:04:04 -0800 Subject: [PATCH 4/4] change machine type to one available in central region --- .github/workflows/zcashd-cd.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/zcashd-cd.yml b/.github/workflows/zcashd-cd.yml index b5748ac2925..ccb2d68bc9e 100644 --- a/.github/workflows/zcashd-cd.yml +++ b/.github/workflows/zcashd-cd.yml @@ -11,7 +11,6 @@ on: env: PROJECT_ID: zealous-zebra REGION: us-central1 - ZONE: us-central1-c jobs: @@ -44,7 +43,7 @@ jobs: --boot-disk-size 100GB \ --container-image "electriccoinco/zcashd" \ --container-env ZCASHD_NETWORK="${{ github.event.inputs.network }}" \ - --machine-type n2d-standard-4 \ + --machine-type n2-standard-4 \ --service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \ --scopes cloud-platform \ --tags zcashd \