-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (209 loc) · 7.79 KB
/
release.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: release
# 1. Run unit and integration tests
# 2. Push containers to AWS ECR and dockerhub tagged with release
# 3. Recommit an update to the chart's deployments with the updated build number in the `deployment` branch
on:
release:
types: [created]
tags:
- "v*.*.*"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install deps
run: |
pip3 install -r requirements_api.txt -r requirements_worker.txt -r requirements_dev.txt
pip3 install --upgrade protobuf
- name: Bring up stack
run: make up-dbs && sleep 30
- name: Check stack
run: make ps
- name: Run tests with coverage
run: make test-coverage
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
- name: Tag name
id: source
run: |
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_WORKER }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_WORKER }}
aws-region: us-west-2
- name: Login to Amazon ECR
id: login-ecr-worker
uses: aws-actions/amazon-ecr-login@v1
- name: Worker - Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr-worker.outputs.registry }}
ECR_REPOSITORY: icon-metrics-worker
IMAGE_TAG: prod-${{ steps.source.outputs.TAG }}
run: |
docker build --target prod --build-arg SERVICE_NAME=worker -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_API }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_API }}
aws-region: us-west-2
- name: Login to Amazon ECR
id: login-ecr-api
uses: aws-actions/amazon-ecr-login@v1
- name: API - Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr-api.outputs.registry }}
ECR_REPOSITORY: icon-metrics-api
IMAGE_TAG: prod-${{ steps.source.outputs.TAG }}
run: |
docker build --target prod --build-arg SERVICE_NAME=api -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push (API) - latest
uses: docker/build-push-action@v2
with:
context: .
build-args: |
SERVICE_NAME=api
file: ./Dockerfile
target: prod
push: true
tags: geometrylabs/icon-metrics-api:latest
- name: Build and push (API)
uses: docker/build-push-action@v2
with:
context: .
build-args: |
SERVICE_NAME=api
file: ./Dockerfile
target: prod
push: true
tags: geometrylabs/icon-metrics-api:${{ steps.source.outputs.TAG }}
- name: Build and push (WORKER) - latest
uses: docker/build-push-action@v2
with:
context: .
build-args: |
SERVICE_NAME=api
file: ./Dockerfile
target: prod
push: true
tags: geometrylabs/icon-metrics-api:latest
- name: Build and push (WORKER)
uses: docker/build-push-action@v2
with:
context: .
build-args: |
SERVICE_NAME=api
file: ./Dockerfile
target: prod
push: true
tags: geometrylabs/icon-metrics-api:${{ steps.source.outputs.TAG }}
- name: Checkout charts repo
uses: actions/checkout@v2
with:
repository: geometry-labs/icon-charts
ref: main
path: charts
token: ${{ secrets.ICON_CHARTS_PAT }}
- name: Update prod-sejong-us-west-2 deployment values file (API)
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-us-west-2/sejong/metrics/values.yaml'
propertyPath: 'api.image.tag'
value: prod-${{ steps.source.outputs.TAG }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Update prod-sejong-us-west-2 deployment values file (WORKER)
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-us-west-2/sejong/metrics/values.yaml'
propertyPath: 'worker.image.tag'
value: prod-${{ steps.source.outputs.TAG }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Update prod-mainnet-eu-west-1 deployment values file (API)
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-eu-west-1/mainnet/metrics/values.yaml'
propertyPath: 'api.image.tag'
value: prod-${{ steps.source.outputs.TAG }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Update prod-mainnet-eu-west-1 deployment values file (WORKER)
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-eu-west-1/mainnet/metrics/values.yaml'
propertyPath: 'worker.image.tag'
value: prod-${{ steps.source.outputs.TAG }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Update prod-mainnet-us-west-2 deployment values file (API)
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-us-west-2/mainnet/metrics/values.yaml'
propertyPath: 'api.image.tag'
value: prod-${{ steps.source.outputs.TAG }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Update prod-mainnet-us-west-2 deployment values file (WORKER) and re-commit
uses: fjogeleit/yaml-update-action@master
with:
workDir: charts
repository: geometry-labs/icon-charts
valueFile: 'deployments/prod-us-west-2/mainnet/metrics/values.yaml'
propertyPath: 'worker.image.tag'
value: prod-${{ steps.source.outputs.TAG }}
branch: main
createPR: 'false'
updateFile: true
commitChange: false
- name: Configure credentials
uses: oleksiyrudenko/gha-git-credentials@v2-latest
with:
token: '${{ secrets.ICON_CHARTS_PAT }}'
global: true
- name: Commit all updates
run: |
git add -A
git commit -m "metrics prod deployment (mainnet) image versions to ${{ steps.source.outputs.TAG }}"
git push origin
working-directory: charts
- name: Push tags
run: |
git tag -f metrics-prod-uswest2
git tag -f metrics-prod-euwest1
git push -f origin --tags
working-directory: charts