-
Notifications
You must be signed in to change notification settings - Fork 22
167 lines (147 loc) · 5.44 KB
/
deploy_mainnet.yml
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# The Licensed Work is (c) 2022 Sygma
# SPDX-License-Identifier: BUSL-1.1
name: Sygma Mainnet
on:
workflow_dispatch:
inputs:
release_tag:
description: 'The Release tag Version'
required: true
type: string
TOKEN:
description: 'Authentication token'
required: true
type: string
run-name: Deploy Relayers to Mainnet - ${{ inputs.release_tag }} by @${{ github.actor }}
env:
ENVIRONMENT: 'MAINNET'
REGISTRY: 'ghcr.io'
jobs:
######################## region 1 ########################
deploy_region_1:
name: deploy
runs-on: ubuntu-latest
environment: mainnet
strategy:
matrix:
relayer_id: [0, 1]
env:
AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
permissions:
contents: read
id-token: write
steps:
- name: Authentication
id: auth
run: |
if [ "${{ secrets.AUTH_TOKEN }}" != "${{ github.event.inputs.TOKEN }}" ]; then
echo "Authentcation failed. Exiting..."
exit 1
fi
- name: Continue
if: steps.auth.outcome == 'success'
run: |
echo 'Authentication Succeeded!!!'
- name: checkout ecs repo
uses: actions/checkout@v3
with:
repository: sprintertech/devops
token: ${{ secrets.GHCR_TOKEN }}
- name: render jinja2 templates to task definition json files
uses: cuchi/[email protected]
with:
template: 'relayers/ecs/task_definition-${{ env.ENVIRONMENT }}.j2'
output_file: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}.json'
data_format: json
variables: |
relayerId=${{ matrix.relayer_id }}
awsAccountId=${{ env.AWS_MAINNET }}
awsRegion=${{ secrets.AWS_REGION_1 }}
imageTag=${{ inputs.release_tag }}
awsEnv=${{ env.ENVIRONMENT }}
awsEfs=${{ secrets.MAINNET_EFS_1 }}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_MAINNET }}:role/github-actions-${{ env.ENVIRONMENT }}-chainbridge
aws-region: ${{ secrets.AWS_REGION_1 }}
role-session-name: GithubActions
- name: deploy task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}.json'
service: 'relayer-${{ matrix.relayer_id }}-service-${{ env.ENVIRONMENT }}'
cluster: 'relayer-${{ env.ENVIRONMENT }}'
wait-for-service-stability: true
- name: slack notify
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,job,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always()
######################## region 3 ########################
deploy_region_3:
name: deploy
runs-on: ubuntu-latest
environment: mainnet
strategy:
matrix:
relayer_id: [2]
env:
AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
permissions:
contents: read
id-token: write
steps:
- name: Authentication
id: auth
run: |
if [ "${{ secrets.AUTH_TOKEN }}" != "${{ github.event.inputs.TOKEN }}" ]; then
echo "Authentcation failed. Exiting..."
exit 1
fi
- name: Continue
if: steps.auth.outcome == 'success'
run: |
echo 'Authentication Succeeded!!!'
- name: checkout ecs repo
uses: actions/checkout@v3
with:
repository: sprintertech/devops
token: ${{ secrets.GHCR_TOKEN }}
- name: render jinja2 templates to task definition json files
uses: cuchi/[email protected]
with:
template: 'relayers/ecs/task_definition-${{ env.ENVIRONMENT }}.j2'
output_file: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}.json'
data_format: json
variables: |
relayerId=${{ matrix.relayer_id }}
awsAccountId=${{ env.AWS_MAINNET }}
awsRegion=${{ secrets.AWS_REGION_3 }}
imageTag=${{ inputs.release_tag }}
awsEnv=${{ env.ENVIRONMENT }}
awsEfs=${{ secrets.MAINNET_EFS_3 }}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_MAINNET }}:role/github-actions-${{ env.ENVIRONMENT }}-chainbridge
aws-region: ${{ secrets.AWS_REGION_3 }}
role-session-name: GithubActions
- name: deploy task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: 'relayers/ecs/task_definition-${{ matrix.relayer_id }}_${{ env.ENVIRONMENT }}.json'
service: 'relayer-${{ matrix.relayer_id }}-service-${{ env.ENVIRONMENT }}'
cluster: 'relayer-${{ env.ENVIRONMENT }}'
wait-for-service-stability: true
- name: slack notify
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,job,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always()