2020-06-21 01:39:47 -07:00
|
|
|
name: CD
|
2020-06-08 18:03:51 -07:00
|
|
|
|
2022-08-29 17:11:05 -07:00
|
|
|
# Ensures that only one workflow task will run at a time. Previous deployments, if
|
|
|
|
# already in process, won't get cancelled. Instead, we let the first to complete
|
2023-06-07 22:44:30 -07:00
|
|
|
# then queue the latest pending workflow, cancelling any workflows in between.
|
|
|
|
#
|
|
|
|
# Since the different event types each use a different Managed Instance Group or instance,
|
|
|
|
# we can run different event types concurrently.
|
2023-06-25 16:24:10 -07:00
|
|
|
#
|
|
|
|
# For pull requests, we only run the tests from this workflow, and don't do any deployments.
|
|
|
|
# So an in-progress pull request gets cancelled, just like other tests.
|
2022-08-29 17:11:05 -07:00
|
|
|
concurrency:
|
2023-06-07 22:44:30 -07:00
|
|
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
|
2023-06-25 16:24:10 -07:00
|
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
2022-08-29 17:11:05 -07:00
|
|
|
|
2020-06-08 18:03:51 -07:00
|
|
|
on:
|
2020-11-19 12:21:03 -08:00
|
|
|
workflow_dispatch:
|
2022-02-08 16:50:13 -08:00
|
|
|
inputs:
|
|
|
|
network:
|
|
|
|
default: 'Mainnet'
|
2022-04-11 22:06:37 -07:00
|
|
|
description: 'Network to deploy: Mainnet or Testnet'
|
|
|
|
required: true
|
2023-06-07 22:44:30 -07:00
|
|
|
log_file:
|
2023-06-09 00:41:09 -07:00
|
|
|
default: ''
|
2023-06-07 22:44:30 -07:00
|
|
|
description: 'Log to a file path rather than standard output'
|
|
|
|
no_cache:
|
|
|
|
description: 'Disable the Docker cache for this build'
|
|
|
|
required: false
|
|
|
|
type: boolean
|
|
|
|
default: false
|
2023-06-25 16:24:10 -07:00
|
|
|
|
2023-06-09 08:30:37 -07:00
|
|
|
# Temporarily disabled to reduce network load, see #6894.
|
|
|
|
#push:
|
|
|
|
# branches:
|
|
|
|
# - main
|
2023-06-25 16:24:10 -07:00
|
|
|
# paths:
|
|
|
|
# # code and tests
|
|
|
|
# - '**/*.rs'
|
|
|
|
# # hard-coded checkpoints and proptest regressions
|
|
|
|
# - '**/*.txt'
|
|
|
|
# # dependencies
|
|
|
|
# - '**/Cargo.toml'
|
|
|
|
# - '**/Cargo.lock'
|
|
|
|
# # configuration files
|
|
|
|
# - '.cargo/config.toml'
|
|
|
|
# - '**/clippy.toml'
|
|
|
|
# # workflow definitions
|
|
|
|
# - 'docker/**'
|
|
|
|
# - '.dockerignore'
|
|
|
|
# - '.github/workflows/continous-delivery.yml'
|
|
|
|
# - '.github/workflows/build-docker-image.yml'
|
|
|
|
|
|
|
|
# Only runs the Docker image tests, doesn't deploy any instances
|
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
# code and tests
|
|
|
|
- '**/*.rs'
|
|
|
|
# hard-coded checkpoints and proptest regressions
|
|
|
|
- '**/*.txt'
|
|
|
|
# dependencies
|
|
|
|
- '**/Cargo.toml'
|
|
|
|
- '**/Cargo.lock'
|
|
|
|
# configuration files
|
|
|
|
- '.cargo/config.toml'
|
|
|
|
- '**/clippy.toml'
|
|
|
|
# workflow definitions
|
|
|
|
- 'docker/**'
|
|
|
|
- '.dockerignore'
|
|
|
|
- '.github/workflows/continous-delivery.yml'
|
|
|
|
- '.github/workflows/find-cached-disks.yml'
|
|
|
|
|
2022-08-28 05:46:21 -07:00
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
2020-06-08 18:03:51 -07:00
|
|
|
|
2023-06-25 16:24:10 -07:00
|
|
|
|
2020-06-08 18:03:51 -07:00
|
|
|
jobs:
|
2022-08-28 05:46:21 -07:00
|
|
|
# If a release was made we want to extract the first part of the semver from the
|
|
|
|
# tag_name
|
|
|
|
#
|
|
|
|
# Generate the following output to pass to subsequent jobs
|
|
|
|
# - If our semver is `v1.3.0` the resulting output from this job would be `v1`
|
|
|
|
#
|
|
|
|
# Note: We just use the first part of the version to replace old instances, and change
|
2022-11-25 13:11:22 -08:00
|
|
|
# it when a major version is released, to keep a segregation between new and old
|
2022-08-28 05:46:21 -07:00
|
|
|
# versions.
|
|
|
|
versioning:
|
|
|
|
name: Versioning
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
major_version: ${{ steps.set.outputs.major_version }}
|
2022-08-28 16:56:58 -07:00
|
|
|
if: ${{ github.event_name == 'release' }}
|
2022-08-28 05:46:21 -07:00
|
|
|
steps:
|
|
|
|
- name: Getting Zebrad Version
|
|
|
|
id: get
|
2023-04-10 23:12:21 -07:00
|
|
|
uses: actions/github-script@v6.4.1
|
2022-08-28 05:46:21 -07:00
|
|
|
with:
|
|
|
|
result-encoding: string
|
|
|
|
script: |
|
|
|
|
return context.payload.release.tag_name.substring(0,2)
|
|
|
|
- name: Setting API Version
|
|
|
|
id: set
|
2023-01-31 12:40:05 -08:00
|
|
|
run: echo "major_version=${{ steps.get.outputs.result }}" >> "$GITHUB_OUTPUT"
|
2022-08-28 05:46:21 -07:00
|
|
|
|
|
|
|
# Each time this workflow is executed, a build will be triggered to create a new image
|
|
|
|
# with the corresponding tags using information from Git
|
|
|
|
#
|
|
|
|
# The image will be commonly named `zebrad:<short-hash | github-ref | semver>`
|
2020-06-08 18:03:51 -07:00
|
|
|
build:
|
2022-11-06 17:59:32 -08:00
|
|
|
name: Build CD Docker
|
2022-05-09 12:54:16 -07:00
|
|
|
uses: ./.github/workflows/build-docker-image.yml
|
2022-04-28 01:13:35 -07:00
|
|
|
with:
|
|
|
|
dockerfile_path: ./docker/Dockerfile
|
|
|
|
dockerfile_target: runtime
|
|
|
|
image_name: zebrad
|
2023-06-07 22:44:30 -07:00
|
|
|
no_cache: ${{ inputs.no_cache || false }}
|
|
|
|
# We hard-code Mainnet here, because the config is modified before running zebrad
|
|
|
|
network: 'Mainnet'
|
2022-04-28 01:13:35 -07:00
|
|
|
rust_backtrace: '1'
|
|
|
|
zebra_skip_ipv6_tests: '1'
|
|
|
|
rust_log: info
|
2022-02-08 16:50:13 -08:00
|
|
|
|
2023-07-12 02:33:51 -07:00
|
|
|
# Test that Zebra works using the default config with the latest Zebra version.
|
2023-01-22 22:41:59 -08:00
|
|
|
test-configuration-file:
|
2023-06-25 18:12:29 -07:00
|
|
|
name: Test Zebra CD Docker config file
|
2023-06-07 22:44:30 -07:00
|
|
|
timeout-minutes: 15
|
2023-01-22 22:41:59 -08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
steps:
|
2023-05-18 09:44:39 -07:00
|
|
|
- uses: r7kamura/rust-problem-matchers@v1.3.0
|
|
|
|
|
2023-01-22 22:41:59 -08:00
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4
|
|
|
|
with:
|
|
|
|
short-length: 7
|
|
|
|
|
2023-06-07 22:44:30 -07:00
|
|
|
# Make sure Zebra can sync at least one full checkpoint on mainnet
|
2023-01-22 22:41:59 -08:00
|
|
|
- name: Run tests using the default config
|
|
|
|
run: |
|
|
|
|
set -ex
|
2023-04-12 23:56:21 -07:00
|
|
|
docker pull ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }}
|
|
|
|
docker run --detach --name default-conf-tests -t ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }}
|
2023-06-07 22:44:30 -07:00
|
|
|
# show the logs, even if the job times out
|
|
|
|
docker logs --tail all --follow default-conf-tests | \
|
|
|
|
tee --output-error=exit /dev/stderr | \
|
|
|
|
grep --max-count=1 --extended-regexp --color=always \
|
|
|
|
'net.*=.*Main.*estimated progress to chain tip.*BeforeOverwinter'
|
2023-01-22 22:41:59 -08:00
|
|
|
docker stop default-conf-tests
|
2023-06-07 22:44:30 -07:00
|
|
|
# get the exit status from docker
|
|
|
|
EXIT_STATUS=$( \
|
|
|
|
docker wait default-conf-tests || \
|
|
|
|
docker inspect --format "{{.State.ExitCode}}" default-conf-tests || \
|
|
|
|
echo "missing container, or missing exit status for container" \
|
|
|
|
)
|
2023-01-22 22:41:59 -08:00
|
|
|
docker logs default-conf-tests
|
2023-06-07 22:44:30 -07:00
|
|
|
echo "docker exit status: $EXIT_STATUS"
|
|
|
|
if [[ "$EXIT_STATUS" = "137" ]]; then
|
|
|
|
echo "ignoring expected signal status"
|
|
|
|
exit 0
|
|
|
|
fi
|
2023-01-22 22:41:59 -08:00
|
|
|
exit "$EXIT_STATUS"
|
|
|
|
|
2023-07-12 02:33:51 -07:00
|
|
|
# Test reconfiguring the docker image for testnet.
|
|
|
|
test-configuration-file-testnet:
|
|
|
|
name: Test testnet Zebra CD Docker config file
|
|
|
|
timeout-minutes: 15
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
steps:
|
|
|
|
- uses: r7kamura/rust-problem-matchers@v1.3.0
|
|
|
|
|
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4
|
|
|
|
with:
|
|
|
|
short-length: 7
|
|
|
|
|
2023-06-07 22:44:30 -07:00
|
|
|
# Make sure Zebra can sync the genesis block on testnet
|
|
|
|
- name: Run tests using a testnet config
|
|
|
|
run: |
|
|
|
|
set -ex
|
|
|
|
docker pull ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }}
|
|
|
|
docker run --env "NETWORK=Testnet" --detach --name testnet-conf-tests -t ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }}
|
|
|
|
# show the logs, even if the job times out
|
|
|
|
docker logs --tail all --follow testnet-conf-tests | \
|
|
|
|
tee --output-error=exit /dev/stderr | \
|
|
|
|
grep --max-count=1 --extended-regexp --color=always \
|
2023-06-27 19:35:20 -07:00
|
|
|
-e 'net.*=.*Test.*estimated progress to chain tip.*Genesis' \
|
|
|
|
-e 'net.*=.*Test.*estimated progress to chain tip.*BeforeOverwinter'
|
2023-06-07 22:44:30 -07:00
|
|
|
docker stop testnet-conf-tests
|
|
|
|
# get the exit status from docker
|
|
|
|
EXIT_STATUS=$( \
|
|
|
|
docker wait testnet-conf-tests || \
|
|
|
|
docker inspect --format "{{.State.ExitCode}}" testnet-conf-tests || \
|
|
|
|
echo "missing container, or missing exit status for container" \
|
|
|
|
)
|
|
|
|
docker logs testnet-conf-tests
|
|
|
|
echo "docker exit status: $EXIT_STATUS"
|
|
|
|
if [[ "$EXIT_STATUS" = "137" ]]; then
|
|
|
|
echo "ignoring expected signal status"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
exit "$EXIT_STATUS"
|
|
|
|
|
|
|
|
# Deploy Managed Instance Groups (MiGs) for Mainnet and Testnet,
|
|
|
|
# with one node in the configured GCP region.
|
2022-08-28 05:46:21 -07:00
|
|
|
#
|
2023-06-07 22:44:30 -07:00
|
|
|
# Separate Mainnet and Testnet MiGs are deployed whenever there are:
|
|
|
|
# - pushes to the main branch, or
|
|
|
|
# - version releases of Zebra.
|
|
|
|
#
|
|
|
|
# Once this workflow is triggered:
|
|
|
|
# - by pushes to main: the MiG is always replaced,
|
|
|
|
# - by releases: the MiG is only replaced if the same major version is being deployed,
|
|
|
|
# otherwise a new major version is deployed in a new MiG.
|
2022-08-28 05:46:21 -07:00
|
|
|
#
|
|
|
|
# Runs:
|
|
|
|
# - on every push/merge to the `main` branch
|
|
|
|
# - on every release, when it's published
|
2022-02-08 16:50:13 -08:00
|
|
|
deploy-nodes:
|
2023-06-07 22:44:30 -07:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
network: [Mainnet, Testnet]
|
|
|
|
name: Deploy ${{ matrix.network }} nodes
|
2023-01-22 22:41:59 -08:00
|
|
|
needs: [ build, test-configuration-file, versioning ]
|
2020-11-12 12:18:35 -08:00
|
|
|
runs-on: ubuntu-latest
|
2023-06-07 22:44:30 -07:00
|
|
|
timeout-minutes: 60
|
2022-03-18 14:25:35 -07:00
|
|
|
permissions:
|
|
|
|
contents: 'read'
|
|
|
|
id-token: 'write'
|
2022-08-28 16:56:58 -07:00
|
|
|
if: ${{ !cancelled() && !failure() && ((github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'release') }}
|
2022-02-08 16:50:13 -08:00
|
|
|
|
2020-11-12 12:18:35 -08:00
|
|
|
steps:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
2023-01-10 02:11:11 -08:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
|
refactor (actions): make better use of variables, secrets and versions (#3393)
* style: use global variables and don't double print
Remove repeated instances of global environment variables. Do not print ENV variables on the terminal as GitHub Actions already shows it.
* fix (actions): Use fixed major versions for actions
As actions get recurrent fixes, using a specific version causes more maintance on the pipelines.
On the other hand, using @master versions could make some action unreliable, as breaking changes might be included without further notice, and even change behavior on a daily basis.
* refactor: make better use of ENV variables
A whole step with refex was being used to extract different variables from GitHub's environment. This gets depecrated in favor of using `rlespinasse/github-slug-action@v4` which has slug URL variables.
A SLUG on a variable will:
- put the variable content in lower case
- replace any character by - except 0-9, a-z, ., and _
- remove leading and trailing - character
- limit the string size to 63 characters
This changes also takes care of using the Head or Base branch for deployments. This will allow us tomerge of workflows, as most steps on this deployment actions are very similar, with little variations between workflows.
* fix (actions): use secrets for sensitive information
* revert: use specific versions for dependabot
Reverting commit 8c934099028e0651e464678c096d8d3815efe95c
2022-01-26 17:46:18 -08:00
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4
|
2022-03-21 16:07:01 -07:00
|
|
|
with:
|
|
|
|
short-length: 7
|
2020-11-12 12:18:35 -08:00
|
|
|
|
2022-11-25 13:11:22 -08:00
|
|
|
# Makes the Zcash network name lowercase.
|
|
|
|
#
|
|
|
|
# Labels in GCP are required to be in lowercase, but the blockchain network
|
2023-06-07 22:44:30 -07:00
|
|
|
# uses sentence case, so we need to downcase the network.
|
2022-11-25 13:11:22 -08:00
|
|
|
#
|
|
|
|
# Passes the lowercase network to subsequent steps using $NETWORK env variable.
|
|
|
|
- name: Downcase network name for labels
|
|
|
|
run: |
|
2023-06-07 22:44:30 -07:00
|
|
|
NETWORK_CAPS="${{ matrix.network }}"
|
2022-11-25 13:11:22 -08:00
|
|
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
|
|
|
|
2020-11-12 12:18:35 -08:00
|
|
|
# Setup gcloud CLI
|
2022-02-08 16:50:13 -08:00
|
|
|
- name: Authenticate to Google Cloud
|
|
|
|
id: auth
|
2023-05-10 19:39:36 -07:00
|
|
|
uses: google-github-actions/auth@v1.1.1
|
2022-02-08 16:50:13 -08:00
|
|
|
with:
|
2022-08-23 20:49:55 -07:00
|
|
|
retries: '3'
|
2023-04-12 23:56:21 -07:00
|
|
|
workload_identity_provider: '${{ vars.GCP_WIF }}'
|
|
|
|
service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}'
|
2022-11-09 22:32:21 -08:00
|
|
|
|
|
|
|
- name: Set up Cloud SDK
|
2023-05-13 18:34:22 -07:00
|
|
|
uses: google-github-actions/setup-gcloud@v1.1.1
|
2020-11-12 12:18:35 -08:00
|
|
|
|
2022-11-22 14:20:47 -08:00
|
|
|
# TODO we should implement the fixes from https://github.com/ZcashFoundation/zebra/pull/5670 here
|
|
|
|
# but the implementation is failing as it's requiring the disk names, contrary to what is stated in the official documentation
|
2023-06-07 22:44:30 -07:00
|
|
|
- name: Create instance template for ${{ matrix.network }}
|
2020-11-12 12:18:35 -08:00
|
|
|
run: |
|
2023-06-07 22:44:30 -07:00
|
|
|
gcloud compute instance-templates create-with-container zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \
|
2023-06-09 12:16:39 -07:00
|
|
|
--boot-disk-size 300GB \
|
2022-02-08 16:50:13 -08:00
|
|
|
--boot-disk-type=pd-ssd \
|
2022-11-16 15:08:28 -08:00
|
|
|
--image-project=cos-cloud \
|
|
|
|
--image-family=cos-stable \
|
2023-06-07 22:44:30 -07:00
|
|
|
--user-output-enabled \
|
2023-06-09 12:16:39 -07:00
|
|
|
--metadata google-logging-enabled=true,google-logging-use-fluentbit=true,google-monitoring-enabled=true \
|
|
|
|
--container-stdin \
|
|
|
|
--container-tty \
|
2023-04-12 23:56:21 -07:00
|
|
|
--container-image ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \
|
2023-06-09 00:41:09 -07:00
|
|
|
--container-env "NETWORK=${{ matrix.network }},LOG_FILE=${{ vars.CD_LOG_FILE }},LOG_COLOR=false,SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \
|
2023-06-09 12:16:39 -07:00
|
|
|
--create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},device-name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd,mode=rw \
|
|
|
|
--container-mount-disk=mount-path='/var/cache/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},mode=rw \
|
2023-04-12 23:56:21 -07:00
|
|
|
--machine-type ${{ vars.GCP_SMALL_MACHINE }} \
|
2023-05-09 17:45:32 -07:00
|
|
|
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
2023-05-09 14:13:26 -07:00
|
|
|
--service-account ${{ vars.GCP_DEPLOYMENTS_SA }} \
|
2020-06-15 01:32:51 -07:00
|
|
|
--scopes cloud-platform \
|
2022-11-25 13:11:22 -08:00
|
|
|
--labels=app=zebrad,environment=prod,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
2023-05-09 19:06:18 -07:00
|
|
|
--tags zebrad
|
2020-06-18 14:52:53 -07:00
|
|
|
|
2020-11-12 12:18:35 -08:00
|
|
|
# Check if our destination instance group exists already
|
2023-06-07 22:44:30 -07:00
|
|
|
- name: Check if ${{ matrix.network }} instance group exists
|
2020-11-12 12:18:35 -08:00
|
|
|
id: does-group-exist
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
2023-06-07 22:44:30 -07:00
|
|
|
gcloud compute instance-groups list | grep "zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${NETWORK}" | grep "${{ vars.GCP_REGION }}"
|
2020-11-12 12:18:35 -08:00
|
|
|
|
|
|
|
# Deploy new managed instance group using the new instance template
|
2023-06-07 22:44:30 -07:00
|
|
|
- name: Create managed instance group for ${{ matrix.network }}
|
2020-11-12 12:18:35 -08:00
|
|
|
if: steps.does-group-exist.outcome == 'failure'
|
|
|
|
run: |
|
|
|
|
gcloud compute instance-groups managed create \
|
2023-06-07 22:44:30 -07:00
|
|
|
"zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${NETWORK}" \
|
|
|
|
--template "zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK}" \
|
2020-06-21 01:39:47 -07:00
|
|
|
--health-check zebrad-tracing-filter \
|
|
|
|
--initial-delay 30 \
|
2023-04-12 23:56:21 -07:00
|
|
|
--region "${{ vars.GCP_REGION }}" \
|
2022-11-22 14:20:47 -08:00
|
|
|
--size 1
|
2020-06-19 00:26:31 -07:00
|
|
|
|
2020-11-12 12:18:35 -08:00
|
|
|
# Rolls out update to existing group using the new instance template
|
2023-06-07 22:44:30 -07:00
|
|
|
- name: Update managed instance group for ${{ matrix.network }}
|
2020-11-12 12:18:35 -08:00
|
|
|
if: steps.does-group-exist.outcome == 'success'
|
|
|
|
run: |
|
|
|
|
gcloud compute instance-groups managed rolling-action start-update \
|
2023-06-07 22:44:30 -07:00
|
|
|
"zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${NETWORK}" \
|
|
|
|
--version template="zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK}" \
|
2023-04-12 23:56:21 -07:00
|
|
|
--region "${{ vars.GCP_REGION }}"
|
2022-02-08 16:50:13 -08:00
|
|
|
|
2023-06-07 22:44:30 -07:00
|
|
|
# This jobs handles the deployment of a single node (1) in the configured GCP zone
|
2022-08-28 05:46:21 -07:00
|
|
|
# when an instance is required to test a specific commit
|
|
|
|
#
|
|
|
|
# Runs:
|
|
|
|
# - on request, using workflow_dispatch with regenerate-disks
|
|
|
|
#
|
|
|
|
# Note: this instances are not automatically replaced or deleted
|
2022-02-08 16:50:13 -08:00
|
|
|
deploy-instance:
|
2023-06-07 22:44:30 -07:00
|
|
|
name: Deploy single ${{ inputs.network }} instance
|
2023-01-22 22:41:59 -08:00
|
|
|
needs: [ build, test-configuration-file ]
|
2022-02-08 16:50:13 -08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 30
|
2022-03-18 14:25:35 -07:00
|
|
|
permissions:
|
|
|
|
contents: 'read'
|
|
|
|
id-token: 'write'
|
2022-02-08 16:50:13 -08:00
|
|
|
if: github.event_name == 'workflow_dispatch'
|
|
|
|
|
|
|
|
steps:
|
2023-06-09 17:59:58 -07:00
|
|
|
- uses: actions/checkout@v3.5.3
|
2023-01-10 02:11:11 -08:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4
|
2022-03-21 16:07:01 -07:00
|
|
|
with:
|
|
|
|
short-length: 7
|
2022-02-08 16:50:13 -08:00
|
|
|
|
2023-06-07 22:44:30 -07:00
|
|
|
# Makes the Zcash network name lowercase.
|
|
|
|
#
|
|
|
|
# Labels in GCP are required to be in lowercase, but the blockchain network
|
|
|
|
# uses sentence case, so we need to downcase the network.
|
|
|
|
#
|
|
|
|
# Passes the lowercase network to subsequent steps using $NETWORK env variable.
|
|
|
|
- name: Downcase network name for labels
|
|
|
|
run: |
|
|
|
|
NETWORK_CAPS="${{ inputs.network }}"
|
|
|
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
|
|
|
|
2022-02-08 16:50:13 -08:00
|
|
|
# Setup gcloud CLI
|
|
|
|
- name: Authenticate to Google Cloud
|
|
|
|
id: auth
|
2023-05-10 19:39:36 -07:00
|
|
|
uses: google-github-actions/auth@v1.1.1
|
2022-02-08 16:50:13 -08:00
|
|
|
with:
|
2022-08-23 20:49:55 -07:00
|
|
|
retries: '3'
|
2023-04-12 23:56:21 -07:00
|
|
|
workload_identity_provider: '${{ vars.GCP_WIF }}'
|
|
|
|
service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}'
|
2022-11-09 22:32:21 -08:00
|
|
|
|
|
|
|
- name: Set up Cloud SDK
|
2023-05-13 18:34:22 -07:00
|
|
|
uses: google-github-actions/setup-gcloud@v1.1.1
|
2022-02-08 16:50:13 -08:00
|
|
|
|
|
|
|
# Create instance template from container image
|
2023-06-07 22:44:30 -07:00
|
|
|
- name: Manual deploy of a single ${{ inputs.network }} instance running zebrad
|
2022-02-08 16:50:13 -08:00
|
|
|
run: |
|
2023-06-07 22:44:30 -07:00
|
|
|
gcloud compute instances create-with-container "zebrad-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK}" \
|
2022-10-16 05:01:59 -07:00
|
|
|
--boot-disk-size 300GB \
|
2022-02-08 16:50:13 -08:00
|
|
|
--boot-disk-type=pd-ssd \
|
2022-11-16 15:08:28 -08:00
|
|
|
--image-project=cos-cloud \
|
|
|
|
--image-family=cos-stable \
|
2023-06-07 22:44:30 -07:00
|
|
|
--user-output-enabled \
|
2023-06-09 12:16:39 -07:00
|
|
|
--metadata google-logging-enabled=true,google-logging-use-fluentbit=true,google-monitoring-enabled=true \
|
2022-02-08 16:50:13 -08:00
|
|
|
--container-stdin \
|
|
|
|
--container-tty \
|
2023-04-12 23:56:21 -07:00
|
|
|
--container-image ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \
|
2023-06-09 00:41:09 -07:00
|
|
|
--container-env "NETWORK=${{ inputs.network }},LOG_FILE=${{ inputs.log_file }},LOG_COLOR=false,SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \
|
2023-06-09 12:16:39 -07:00
|
|
|
--create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},device-name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd,mode=rw \
|
|
|
|
--container-mount-disk=mount-path='/var/cache/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},mode=rw \
|
2023-04-12 23:56:21 -07:00
|
|
|
--machine-type ${{ vars.GCP_SMALL_MACHINE }} \
|
2023-05-09 17:45:32 -07:00
|
|
|
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
2023-05-09 14:13:26 -07:00
|
|
|
--service-account ${{ vars.GCP_DEPLOYMENTS_SA }} \
|
2022-11-25 13:11:22 -08:00
|
|
|
--labels=app=zebrad,environment=qa,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
2023-05-09 14:13:26 -07:00
|
|
|
--tags zebrad \
|
|
|
|
--zone ${{ vars.GCP_ZONE }}
|