Skip to content

cd

cd #163

Workflow file for this run

name: cd
on:
workflow_dispatch:
inputs:
deploy_to_staging:
description: "Deploy to staging"
type: boolean
required: true
default: true
deploy_to_prod:
description: "Deploy to production"
type: boolean
required: true
default: false
image_tag:
description: "App image tag. Default: latest release"
type: string
required: false
default: ""
workflow_call:
inputs:
deploy_to_staging:
type: boolean
required: true
default: true
deploy_to_prod:
type: boolean
required: false
default: false
image_tag:
type: string
required: true
concurrency:
# Only allow for one action to run at once, queue any others
group: cd
# Don't cancel existing
cancel-in-progress: false
jobs:
deploy-infra-staging:
if: ${{ inputs.deploy_to_staging }}
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging.echo.walletconnect.com/health
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Get Grafana details
id: grafana-get-details
uses: WalletConnect/actions/aws/grafana/get-details/@1.0.3
- name: Get Grafana key
id: grafana-get-key
uses: WalletConnect/actions/aws/grafana/get-key/@1.0.3
with:
key-prefix: ${{ github.event.repository.name }}
workspace-id: ${{ steps.grafana-get-details.outputs.workspace-id }}
- name: Init Terraform
id: tf-init
uses: WalletConnect/actions/terraform/init/@1.0.3
with:
environment: "staging"
- name: Deploy Terraform to Staging
id: tf-apply
uses: WalletConnect/actions/terraform/apply/@1.0.3
env:
GRAFANA_AUTH: ${{ steps.grafana-get-key.outputs.key }}
TF_VAR_grafana_endpoint: ${{ steps.grafana-get-details.outputs.endpoint }}
TF_VAR_cloud_api_key: ${{ secrets.CLOUD_API_KEY }}
TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET }}
TF_VAR_image_version: ${{ inputs.image_tag }}
TF_VAR_relay_public_key: ${{ secrets.RELAY_PUBLIC_KEY }}
with:
environment: "staging"
- name: Delete Grafana key
id: grafana-delete-key
uses: WalletConnect/actions/aws/grafana/delete-key/@1.0.3
if: ${{ success() || failure() || cancelled() }} # don't use always() since it creates non-cancellable jobs
with:
key-name: ${{ steps.grafana-get-key.outputs.key-name }}
workspace-id: ${{ steps.grafana-get-details.outputs.workspace-id }}
validate_staging:
if: ${{ inputs.deploy_to_staging }}
needs: [deploy-infra-staging]
uses: ./.github/workflows/validate.yml
with:
environment: 'staging'
secrets:
TEST_TENANT_ID: ${{ secrets.TEST_TENANT_ID }}
deploy-infra-prod:
if: ${{ inputs.deploy_to_prod }}
runs-on: ubuntu-latest
environment:
name: prod
url: https://echo.walletconnect.com/health
needs:
- validate_staging
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Get Grafana details
id: grafana-get-details
uses: WalletConnect/actions/aws/grafana/get-details/@1.0.3
- name: Get Grafana key
id: grafana-get-key
uses: WalletConnect/actions/aws/grafana/get-key/@1.0.3
with:
key-prefix: ${{ github.event.repository.name }}
workspace-id: ${{ steps.grafana-get-details.outputs.workspace-id }}
- name: Init Terraform
id: tf-init
uses: WalletConnect/actions/terraform/init/@1.0.3
with:
environment: "prod"
- name: Deploy Terraform to Production
id: tf-apply
uses: WalletConnect/actions/terraform/apply/@1.0.3
env:
GRAFANA_AUTH: ${{ steps.grafana-get-key.outputs.key }}
TF_VAR_grafana_endpoint: ${{ steps.grafana-get-details.outputs.endpoint }}
TF_VAR_cloud_api_key: ${{ secrets.CLOUD_API_KEY }}
TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET }}
TF_VAR_image_version: ${{ inputs.image_tag }}
TF_VAR_relay_public_key: ${{ secrets.RELAY_PUBLIC_KEY }}
with:
environment: "prod"
- name: Delete Grafana key
id: grafana-delete-key
uses: WalletConnect/actions/aws/grafana/delete-key/@1.0.3
if: ${{ success() || failure() || cancelled() }} # don't use always() since it creates non-cancellable jobs
with:
key-name: ${{ steps.grafana-get-key.outputs.key-name }}
workspace-id: ${{ steps.grafana-get-details.outputs.workspace-id }}