2020-06-21 01:39:47 -07:00
|
|
|
name: CD
|
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'
|
|
|
|
checkpoint_sync:
|
|
|
|
default: true
|
2020-06-08 18:03:51 -07:00
|
|
|
push:
|
2020-06-18 23:14:10 -07:00
|
|
|
branches:
|
|
|
|
- main
|
2020-06-08 18:03:51 -07:00
|
|
|
|
2020-06-15 01:32:51 -07:00
|
|
|
env:
|
2022-02-08 16:50:13 -08:00
|
|
|
CARGO_INCREMENTAL: '1'
|
|
|
|
NETWORK: Mainnet
|
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
|
|
|
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
|
2022-02-08 16:50:13 -08:00
|
|
|
GAR_BASE: us-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/zebra
|
|
|
|
GCR_BASE: gcr.io/${{ secrets.GCP_PROJECT_ID }}
|
|
|
|
REGION: us-central1
|
|
|
|
ZONE: us-central1-a
|
|
|
|
MACHINE_TYPE: c2-standard-4
|
2020-06-15 01:32:51 -07:00
|
|
|
|
2020-06-08 18:03:51 -07:00
|
|
|
jobs:
|
|
|
|
build:
|
2020-11-12 12:18:35 -08:00
|
|
|
name: Build images
|
2022-01-26 10:45:08 -08:00
|
|
|
timeout-minutes: 60
|
2020-06-08 18:03:51 -07:00
|
|
|
runs-on: ubuntu-latest
|
2022-02-08 16:50:13 -08:00
|
|
|
|
2020-06-08 18:03:51 -07:00
|
|
|
steps:
|
2021-11-04 22:08:39 -07:00
|
|
|
- uses: actions/checkout@v2.4.0
|
2021-05-16 16:32:38 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2020-06-15 01:32:51 -07:00
|
|
|
|
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
|
2020-06-15 01:32:51 -07:00
|
|
|
|
|
|
|
# Setup gcloud CLI
|
2022-02-08 16:50:13 -08:00
|
|
|
- name: Authenticate to Google Cloud
|
|
|
|
id: auth
|
2022-02-13 04:39:18 -08:00
|
|
|
uses: google-github-actions/auth@v0.6.0
|
2022-02-08 16:50:13 -08:00
|
|
|
with:
|
|
|
|
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
|
|
|
|
|
|
|
|
# Setup Docker Buildx to allow use of docker cache layers from GH
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Login to Google Artifact Registry
|
|
|
|
uses: docker/login-action@v1.12.0
|
|
|
|
with:
|
|
|
|
registry: us-docker.pkg.dev
|
|
|
|
username: _json_key
|
|
|
|
password: ${{ secrets.GOOGLE_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Login to Google Container Registry
|
|
|
|
uses: docker/login-action@v1.12.0
|
|
|
|
with:
|
|
|
|
registry: gcr.io
|
|
|
|
username: _json_key
|
|
|
|
password: ${{ secrets.GOOGLE_CREDENTIALS }}
|
|
|
|
|
|
|
|
# Build and push image to Google Artifact Registry
|
|
|
|
- name: Build & push
|
|
|
|
id: docker_build
|
2022-02-13 04:37:06 -08:00
|
|
|
uses: docker/build-push-action@v2.9.0
|
2020-06-08 18:03:51 -07:00
|
|
|
with:
|
2022-02-08 16:50:13 -08:00
|
|
|
target: runtime
|
|
|
|
context: .
|
|
|
|
file: ./docker/Dockerfile.build
|
|
|
|
tags: |
|
2022-02-16 07:47:02 -08:00
|
|
|
${{ env.GAR_BASE }}/${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}:latest
|
|
|
|
${{ env.GAR_BASE }}/${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}:${{ env.GITHUB_SHA_SHORT }}
|
|
|
|
${{ env.GCR_BASE }}/${{ env.GITHUB_REPOSITORY_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_SLUG_URL }}/${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}:latest
|
|
|
|
${{ env.GCR_BASE }}/${{ env.GITHUB_REPOSITORY_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_SLUG_URL }}/${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}:${{ env.GITHUB_SHA_SHORT }}
|
2022-02-08 16:50:13 -08:00
|
|
|
build-args: |
|
|
|
|
NETWORK=${{ github.event.inputs.network || env.NETWORK }}
|
|
|
|
SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}
|
|
|
|
RUST_BACKTRACE=1
|
|
|
|
ZEBRA_SKIP_IPV6_TESTS="1"
|
|
|
|
CHECKPOINT_SYNC=${{ github.event.inputs.checkpoint_sync || true }}
|
|
|
|
SENTRY_DSN=${{ secrets.SENTRY_ENDPOINT }}
|
|
|
|
push: true
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
|
|
|
|
|
|
|
deploy-nodes:
|
|
|
|
name: Deploy Mainnet nodes
|
2020-11-12 12:18:35 -08:00
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 30
|
2022-02-08 16:50:13 -08:00
|
|
|
if: github.event_name == 'push' && github.ref == 'ref/head/main'
|
|
|
|
|
2020-11-12 12:18:35 -08:00
|
|
|
steps:
|
2021-11-04 22:08:39 -07:00
|
|
|
- uses: actions/checkout@v2.4.0
|
2021-05-16 16:32:38 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2020-11-12 12:18:35 -08:00
|
|
|
|
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
|
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
|
2022-02-13 04:39:18 -08:00
|
|
|
uses: google-github-actions/auth@v0.6.0
|
2022-02-08 16:50:13 -08:00
|
|
|
with:
|
|
|
|
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
|
|
|
|
|
2020-11-12 12:18:35 -08:00
|
|
|
- name: Set up gcloud SDK environment
|
2022-02-08 02:37:26 -08:00
|
|
|
uses: google-github-actions/setup-gcloud@v0.5.0
|
2020-11-12 12:18:35 -08:00
|
|
|
with:
|
|
|
|
project_id: ${{ env.PROJECT_ID }}
|
|
|
|
|
|
|
|
- name: Create instance template
|
|
|
|
run: |
|
2022-02-16 07:47:02 -08:00
|
|
|
gcloud compute instance-templates create-with-container zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
2022-02-08 16:50:13 -08:00
|
|
|
--boot-disk-type=pd-ssd \
|
2022-02-16 07:47:02 -08:00
|
|
|
--container-image ${{ env.GAR_BASE }}/${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}:${{ env.GITHUB_SHA_SHORT }} \
|
2022-02-08 16:50:13 -08:00
|
|
|
--create-disk name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }},auto-delete=yes,size=100GB,type=pd-ssd \
|
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
|
|
|
--container-mount-disk mount-path="/zebrad-cache",name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }} \
|
|
|
|
--machine-type ${{ env.MACHINE_TYPE }} \
|
2020-06-15 01:32:51 -07:00
|
|
|
--scopes cloud-platform \
|
2022-02-08 16:50:13 -08: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
|
|
|
|
- name: Check if instance group exists
|
|
|
|
id: does-group-exist
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
2022-02-16 07:47:02 -08:00
|
|
|
gcloud compute instance-groups list | grep "zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}" | grep "${{ env.REGION }}"
|
2020-11-12 12:18:35 -08:00
|
|
|
|
|
|
|
# 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 \
|
2022-02-16 07:47:02 -08:00
|
|
|
"zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}" \
|
|
|
|
--template "zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
2020-06-21 01:39:47 -07:00
|
|
|
--health-check zebrad-tracing-filter \
|
|
|
|
--initial-delay 30 \
|
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
|
|
|
--region "${{ env.REGION }}" \
|
2020-06-21 01:39:47 -07:00
|
|
|
--size 2
|
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
|
|
|
|
- name: Update managed instance group
|
|
|
|
if: steps.does-group-exist.outcome == 'success'
|
|
|
|
run: |
|
|
|
|
gcloud compute instance-groups managed rolling-action start-update \
|
2022-02-16 07:47:02 -08:00
|
|
|
"zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}" \
|
|
|
|
--version template="zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
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
|
|
|
--region "${{ env.REGION }}"
|
2022-02-08 16:50:13 -08:00
|
|
|
|
|
|
|
deploy-instance:
|
|
|
|
name: Deploy single instance
|
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 30
|
|
|
|
if: github.event_name == 'workflow_dispatch'
|
|
|
|
|
|
|
|
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: Authenticate to Google Cloud
|
|
|
|
id: auth
|
2022-02-13 04:39:18 -08:00
|
|
|
uses: google-github-actions/auth@v0.6.0
|
2022-02-08 16:50:13 -08:00
|
|
|
with:
|
|
|
|
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Set up gcloud SDK environment
|
|
|
|
uses: google-github-actions/setup-gcloud@v0.5.0
|
|
|
|
with:
|
|
|
|
project_id: ${{ env.PROJECT_ID }}
|
|
|
|
|
|
|
|
# Create instance template from container image
|
|
|
|
- name: Manual deploy of a single instance running zebrad
|
|
|
|
run: |
|
2022-02-16 07:47:02 -08:00
|
|
|
gcloud compute instances create-with-container "zebrad-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
2022-02-08 16:50:13 -08:00
|
|
|
--boot-disk-size 100GB \
|
|
|
|
--boot-disk-type=pd-ssd \
|
|
|
|
--container-stdin \
|
|
|
|
--container-tty \
|
2022-02-16 07:47:02 -08:00
|
|
|
--container-image ${{ env.GAR_BASE }}/${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}:${{ env.GITHUB_SHA_SHORT }} \
|
2022-02-08 16:50:13 -08:00
|
|
|
--create-disk name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }},auto-delete=yes,size=100GB,type=pd-ssd \
|
|
|
|
--container-mount-disk mount-path='/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }} \
|
|
|
|
--machine-type ${{ env.MACHINE_TYPE }} \
|
|
|
|
--zone ${{ env.ZONE }} \
|
|
|
|
--tags zebrad
|