Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

deploy-infra

deploy-infra #19

Workflow file for this run

name: deploy-infra
on:
workflow_dispatch:
inputs:
environment:
description: "the environment to deploy to"
required: true
default: "staging"
type: choice
options:
- prod
- staging
environment_url:
description: "the URL of the environment"
required: true
type: string
default: https://cast.walletconnect.com/health
relay_url:
description: "the URL of the relay"
required: true
type: string
default: wss://staging.relay.walletconnect.com
cast_url:
description: "the URL of the cast server"
required: true
type: string
default: https://staging.cast.walletconnect.com
version:
description: "the release version"
required: true
type: string
workflow_call:
inputs:
environment:
description: "the environment to deploy to"
required: true
type: string
default: "staging"
environment_url:
description: "the URL of the environment"
required: true
type: string
default: https://cast.walletconnect.com/health
relay_url:
description: "the URL of the relay"
required: true
type: string
default: wss://staging.relay.walletconnect.com
cast_url:
description: "the URL of the cast server"
required: true
type: string
default: https://staging.cast.walletconnect.com
version:
description: "the release version"
required: true
type: string
jobs:
deploy-infra:
runs-on: ubuntu-latest
environment:
name: infra/${{ inputs.environment }}
url: ${{ inputs.environment_url }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- 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
run: |
WORKSPACE_ID=$(aws grafana list-workspaces | jq -r '.workspaces[] | select( .tags.Env == "prod") | select( .tags.Name == "grafana-9") | .id')
ENDPOINT=$(aws grafana list-workspaces | jq -r '.workspaces[] | select( .tags.Env == "prod") | select( .tags.Name == "grafana-9") | .endpoint')
echo "::set-output name=workspace-id::$WORKSPACE_ID"
echo "::set-output name=endpoint::$ENDPOINT"
- 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: ${{ inputs.environment }}
- name: Deploy Terraform to ${{ inputs.environment }}
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_image_version: ${{ inputs.version}}
TF_VAR_keypair_seed: ${{inputs.environment}}_${{ secrets.KEYPAIR_SEED}}
TF_VAR_project_id: ${{secrets.PROJECT_ID}}
TF_VAR_relay_url: ${{inputs.relay_url}}
TF_VAR_cast_url: ${{inputs.cast_url}}
TF_VAR_data_lake_bucket_key_arn: ${{env.ANALYTICS_DATA_LAKE_KMS_KEY_ARN}}
TF_VAR_registry_auth_token: ${{secrets.registry_auth_token}}
with:
environment: ${{ inputs.environment }}
- 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 }}