-
Notifications
You must be signed in to change notification settings - Fork 3
122 lines (107 loc) · 4.39 KB
/
Copy pathdeploy-auto.yaml
File metadata and controls
122 lines (107 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# TODO: finalize and test this file
# Auto here means we're not providing configuration files for the deployment
# the intention is spin up environments for testing only
name: Deploy TN Auto Environment
on:
workflow_dispatch:
inputs:
NUMBER_OF_NODES:
description: 'Number of nodes to deploy. Max 5.'
required: false
default: 1
type: number
SUBDOMAIN:
# We could enable this once https://github.com/orgs/community/discussions/49688 is resolved
# changing this input create entirely new stacks, then we should be able to better gate who can dispatch this workflow
description: 'Subdomain for the environment. On conflict with existing stack domains, it will fail.'
required: false
default: 'dev'
type: string
jobs:
# tests:
# uses: ./.github/workflows/ci.yaml # don't forget to add `on: [workflow_call]` to permit it
build-and-deploy:
environment: production
name: Build & Deploy
runs-on: ubuntu-latest
# needs: [ tests ] # require tests to pass before deploy runs
steps:
- name: Forbid different subdomain
if: ${{!env.ACT}} # during local testing, it's ok to run other subdomains
run: |
if [ "${{github.event.inputs.SUBDOMAIN}}" != "dev" ]; then
echo "Only dev subdomain is allowed for auto deployments. See code comments for more details."
exit 1
fi
- name: Check secrets
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
GW_SESSION_SECRET: ${{ secrets.GW_SESSION_SECRET }}
# PRIVATE_KEY is the private key of the account that will be used to deploy the TN system contract
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
if: ${{ env.AWS_ACCESS_KEY == '' || env.AWS_SECRET_KEY == '' || env.GW_SESSION_SECRET == '' || env.PRIVATE_KEY == '' }}
run: |
echo "Missing secrets"
exit 1
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Taskfile
uses: arduino/setup-task@v2
- name: Run Taskfile
run: task kwil-binaries
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
check-latest: true
- name: Install dependencies
env:
GH_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
go work init
go work use .
go work use deployments/infra
go mod download
go work vendor
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install AWS CDK
run: npm install -g aws-cdk
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: us-east-2
# this step includes building the docker image. See main_cdk.go for details on args used
- name: Deploy
run: |
cd deployments/infra
# this must be on absolute path
export CDK_DOCKER=$(pwd)/buildx.sh
# this will make sure every run redeploys all the instances
export RESTART_HASH=$(date +%s)
# GW_CORS_ALLOW_ORIGINS = Comma separated list of allowed origins
cdk deploy --require-approval never TN-DB-Auto* TN-Cert* \
--parameters TN-DB-Auto-${{github.event.inputs.SUBDOMAIN}}-Stack:sessionSecret=${{ secrets.GW_SESSION_SECRET }} \
--parameters TN-DB-Auto-${{github.event.inputs.SUBDOMAIN}}-Stack:corsAllowOrigins=${{ secrets.GW_CORS_ALLOW_ORIGINS || '*' }} \
--exclusively \
--context deploymentStage=DEV \
--context specialDomain=${{github.event.inputs.SUBDOMAIN}} \
--context numOfNodes=${{github.event.inputs.NUMBER_OF_NODES}}
env:
CI: true
# path to the kwild CLI binary for configuration generation
KWILD_CLI_PATH: ../../.build/kwild
CHAIN_ID: truflation-dev
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}