name: Zcashd Manual Deploy on: workflow_dispatch: inputs: network: default: 'Mainnet' description: 'Network to deploy: Mainnet or Testnet' required: true size: default: '10' description: 'GCP Managed Instance Group size' required: true env: PROJECT_ID: zealous-zebra REGION: us-central1 ZONE: us-central1-a MACHINE_TYPE: c2-standard-4 jobs: deploy: name: Deploy zcashd nodes runs-on: ubuntu-latest timeout-minutes: 30 permissions: contents: 'read' id-token: 'write' steps: - uses: actions/checkout@v3.0.2 with: persist-credentials: false - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 with: short-length: 7 # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth uses: google-github-actions/auth@v0.8.0 with: workload_identity_provider: 'projects/143793276228/locations/global/workloadIdentityPools/github-actions/providers/github-oidc' service_account: 'github-service-account@zealous-zebra.iam.gserviceaccount.com' token_format: 'access_token' # Create instance template from container image - name: Create instance template run: | gcloud compute instance-templates create-with-container zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \ --boot-disk-size 10GB \ --boot-disk-type=pd-ssd \ --container-stdin \ --container-tty \ --container-image electriccoinco/zcashd \ --container-env ZCASHD_NETWORK="${{ github.event.inputs.network }}" \ --machine-type ${{ env.MACHINE_TYPE }} \ --service-account ${{ env.DEPLOY_SA }} \ --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-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" | grep "${{ env.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-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" \ --template "zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \ --region "${{ env.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-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" \ --version template="zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \ --region "${{ env.REGION }}"