-
Notifications
You must be signed in to change notification settings - Fork 76
361 lines (316 loc) · 14.4 KB
/
Copy pathprerelease.yml
File metadata and controls
361 lines (316 loc) · 14.4 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
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: Deploy to Dev Environment
on:
release:
types: [ prereleased ]
env:
AWS_REGION: "us-west-2"
jobs:
build-web:
name: Build Web Image
runs-on: ubuntu-22.04
environment: staging
outputs:
image: ${{ steps.build-image.outputs.image }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #2.0.1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.event.release.tag_name }}
ECR_REPOSITORY: "advisingapp"
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target web-deploy --platform linux/amd64 --build-arg USER_ID=9999 --build-arg GROUP_ID=9999 .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
deploy-web:
name: Deploy Web Service
runs-on: ubuntu-22.04
needs: [ build-web, deploy-worker ]
environment: staging
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@cbed19f1b86bbb18f59cfffde7107b93cc9b75da #1.8.1
with:
task-definition: "docker/devops/ecs/advisingapp/advisingapp-dev-task-definition.json"
container-name: "app"
image: ${{ needs.build-web.outputs.image }}
- name: Deploy Amazon ECS task definition
id: task-deploy
uses: aws-actions/amazon-ecs-deploy-task-definition@1beffbdddb3eb5f83c7a746c3e9bafeccdccbbaa #2.4.0
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: "advisingapp-dev-service"
cluster: "advisingapp-dev"
wait-for-service-stability: true
- name: Check if deployment was successful
id: check-deployment
run: |
CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster advisingapp-dev --services advisingapp-dev-service --query services[0].deployments[0].taskDefinition | jq -r ".")
NEW_TASK_DEF_ARN=${{ steps.task-deploy.outputs.task-definition-arn }}
echo "Current task arn: $CURRENT_TASK_DEF_ARN"
echo "New task arn: $NEW_TASK_DEF_ARN"
if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then
echo "Deployment failed."
exit 1
fi
build-worker:
name: Build Worker Image
runs-on: ubuntu-22.04
environment: staging
outputs:
image: ${{ steps.build-image.outputs.image }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #2.0.1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.event.release.tag_name }}
ECR_REPOSITORY: "advisingapp/worker"
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target worker-deploy --platform linux/amd64 --build-arg USER_ID=9999 --build-arg GROUP_ID=9999 .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
deploy-worker:
name: Deploy Worker Service
runs-on: ubuntu-22.04
needs: [ build-worker ]
environment: staging
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@cbed19f1b86bbb18f59cfffde7107b93cc9b75da #1.8.1
with:
task-definition: "docker/devops/ecs/advisingapp/advisingapp-worker-dev-task-definition.json"
container-name: "worker"
image: ${{ needs.build-worker.outputs.image }}
- name: Deploy Amazon ECS task definition
id: task-deploy
uses: aws-actions/amazon-ecs-deploy-task-definition@1beffbdddb3eb5f83c7a746c3e9bafeccdccbbaa #2.4.0
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: "advisingapp-worker-dev-service"
cluster: "advisingapp-dev"
wait-for-service-stability: true
- name: Check if deployment was successful
id: check-deployment
run: |
CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster advisingapp-dev --services advisingapp-worker-dev-service --query services[0].deployments[0].taskDefinition | jq -r ".")
NEW_TASK_DEF_ARN=${{ steps.task-deploy.outputs.task-definition-arn }}
echo "Current task arn: $CURRENT_TASK_DEF_ARN"
echo "New task arn: $NEW_TASK_DEF_ARN"
if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then
echo "Deployment failed."
exit 1
fi
build-scheduler:
name: Build Scheduler Image
runs-on: ubuntu-22.04
outputs:
image: ${{ steps.build-image.outputs.image }}
environment: staging
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #2.0.1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.event.release.tag_name }}
ECR_REPOSITORY: "advisingapp/scheduler"
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target scheduler-deploy --platform linux/amd64 --build-arg USER_ID=9999 --build-arg GROUP_ID=9999 .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
deploy-scheduler:
name: Deploy Scheduler Service
runs-on: ubuntu-22.04
needs: [ build-scheduler, deploy-worker ]
environment: staging
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@cbed19f1b86bbb18f59cfffde7107b93cc9b75da #1.8.1
with:
task-definition: "docker/devops/ecs/advisingapp/advisingapp-scheduler-dev-task-definition.json"
container-name: "scheduler"
image: ${{ needs.build-scheduler.outputs.image }}
- name: Deploy Amazon ECS task definition
id: task-deploy
uses: aws-actions/amazon-ecs-deploy-task-definition@1beffbdddb3eb5f83c7a746c3e9bafeccdccbbaa #2.4.0
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: "advisingapp-scheduler-dev-service"
cluster: "advisingapp-dev"
wait-for-service-stability: true
- name: Check if deployment was successful
id: check-deployment
run: |
CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster advisingapp-dev --services advisingapp-scheduler-dev-service --query services[0].deployments[0].taskDefinition | jq -r ".")
NEW_TASK_DEF_ARN=${{ steps.task-deploy.outputs.task-definition-arn }}
echo "Current task arn: $CURRENT_TASK_DEF_ARN"
echo "New task arn: $NEW_TASK_DEF_ARN"
if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then
echo "Deployment failed."
exit 1
fi
build-release-automation:
name: Build Release Automation Image
runs-on: ubuntu-22.04
outputs:
image: ${{ steps.build-image.outputs.image }}
environment: staging
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #2.0.1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.event.release.tag_name }}
ECR_REPOSITORY: "advisingapp/release-automation"
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target release-automation --platform linux/amd64 --build-arg USER_ID=9999 --build-arg GROUP_ID=9999 .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
deploy-release-automation:
name: Deploy and Run Release Automation Service
needs: [ deploy-web, deploy-worker, deploy-scheduler, build-release-automation ]
runs-on: ubuntu-22.04
environment: staging
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
submodules: true
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 #5.1.0
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@cbed19f1b86bbb18f59cfffde7107b93cc9b75da #1.8.1
with:
task-definition: "docker/devops/ecs/advisingapp/advisingapp-release-automation-dev-task-definition.json"
container-name: "release-automation"
image: ${{ needs.build-release-automation.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@1beffbdddb3eb5f83c7a746c3e9bafeccdccbbaa #2.4.0
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
cluster: "advisingapp-dev"
desired-count: 1
run-task: true
run-task-security-groups: ${{ secrets.RELEASE_AUTOMATION_SECURITY_GROUPS }}
run-task-subnets: ${{ secrets.RELEASE_AUTOMATION_SUBNETS }}
run-task-assign-public-IP: "DISABLED"
run-task-launch-type: "FARGATE"
wait-for-task-stopped: true