zebra/.github/workflows/zcashd-manual-deploy.yml

77 lines
2.9 KiB
YAML

name: Zcashd Manual Deploy
on:
workflow_dispatch:
inputs:
network:
default: 'Testnet'
size:
default: 10
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
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
steps:
- uses: actions/checkout@v2.4.0
with:
persist-credentials: false
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
# Setup gcloud CLI
- name: Set up gcloud SDK environment
uses: google-github-actions/setup-gcloud@v0.5.1
with:
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-${{ env.GITHUB_HEAD_REF_SLUG_URL || 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_HEAD_REF_SLUG_URL || 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_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" \
--template "zcashd-${{ env.GITHUB_HEAD_REF_SLUG_URL || 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_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" \
--version template="zcashd-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
--region "${{ env.REGION }}"