-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add manual deploy workflow for zcashd images
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Zcashd Manual Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
network: | ||
default: 'mainnet' | ||
size: | ||
default: 2 | ||
|
||
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 [email protected] \ | ||
--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" |