From 472163f8176c429ed889678d088955bd92f775ed Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Fri, 13 Nov 2020 16:58:25 -0500 Subject: [PATCH] Add a manual zebrad node deploy workflow --- .github/workflows/manual-deploy.yml | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/manual-deploy.yml diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml new file mode 100644 index 00000000..414dabb3 --- /dev/null +++ b/.github/workflows/manual-deploy.yml @@ -0,0 +1,64 @@ +name: Deploy a zebrad node + +on: + workflow_dispatch: + inputs: + network: + default: 'mainnet' + checkpoint_sync: + default: true + +env: + PROJECT_ID: zealous-zebra + +jobs: + + deploy: + runs-on: ubuntu-latest + 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 + + - name: Set up gcloud + uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + with: + version: '295.0.0' + project_id: ${{ env.PROJECT_ID }} + service_account_key: ${{ secrets.GCLOUD_AUTH }} + + # Build and push image to Google Container Registry + - name: Build + # Tagging w/ the commit SHA blocks the :latest tag on GCR + run: | + gcloud builds submit \ + --config cloudbuild.yaml \ + --substitutions SHORT_SHA="$SHORT_SHA",BRANCH_NAME="$BRANCH_NAME" + + # Run once: create firewall rule to allow incoming traffic to the node + # - name: Create Zcash incoming traffic firewall rule + # run: | + # gcloud compute firewall-rules create "allow-zcash" \ + # --target-tags zebrad \ + # --allow tcp:8233,tcp:18233 \ + # --source-ranges 0.0.0.0/0 \ + # --description="Allow incoming Zcash traffic from anywhere" \ + + # Creates Compute Engine virtual machine instance w/ zebrad container and disks + - name: Create instance running zebrad container image + run: | + gcloud compute instances create-with-container "zebra-$BRANCH_NAME-$SHORT_SHA" \ + --container-image "gcr.io/$PROJECT_ID/$REPOSITORY/$BRANCH_NAME:$SHORT_SHA" \ + --container-mount-disk mount-path='/zebrad-cache',name=zebrad-cache-$SHORT_SHA \ + --create-disk name=zebrad-cache-$SHORT_SHA,size=100GB,type=pd-balanced,auto-delete=no \ + --machine-type n2-standard-4 \ + --service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \ + --tags zebrad \ + --zone us-central1-a