Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manual deploy workflow for zcashd images #1844

Merged
merged 4 commits into from
Mar 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/zcashd-cd.yml
Original file line number Diff line number Diff line change
@@ -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
yaahc marked this conversation as resolved.
Show resolved Hide resolved

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,,} && \
yaahc marked this conversation as resolved.
Show resolved Hide resolved
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV && \
echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV && \
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
yaahc marked this conversation as resolved.
Show resolved Hide resolved

# 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" \
yaahc marked this conversation as resolved.
Show resolved Hide resolved
--container-env ZCASHD_NETWORK="${{ github.event.inputs.network }}" \
--machine-type n2d-standard-4 \
--service-account [email protected] \
--scopes cloud-platform \
--tags zcashd \
yaahc marked this conversation as resolved.
Show resolved Hide resolved

# 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"