This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
66 lines (57 loc) · 2.84 KB
/
deployment.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
name: deployment
on:
workflow_dispatch:
inputs:
service-names:
description: 'Service name (multiple services separated by a space), e.g. "auth", "auth checkin", "decision", "event", "gateway", "mail", "notifications", "profile", "project", "registration", "rsvp", "stat", "upload", "user"'
required: false
default: 'auth checkin decision event gateway mail notifications profile project registration rsvp stat upload user'
workflow_call:
inputs:
service-names:
type: "string"
description: 'Service name (multiple services separated by a space), e.g. "auth", "auth checkin", "decision", "event", "gateway", "mail", "notifications", "profile", "project", "registration", "rsvp", "stat", "upload", "user"'
required: false
default: 'auth checkin decision event gateway mail notifications profile project registration rsvp stat upload user'
secrets:
ECS_AWS_ACCESS_KEY_ID:
required: true
ECS_AWS_SECRET_ACCESS_KEY:
required: true
defaults:
run:
shell: bash
jobs:
deploy:
runs-on: ubuntu-20.04
env:
SERVICES: '${{inputs.service-names}}'
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Configure AWS credentials from ECS account
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ECS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECS_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Create new task definition
run:
"for service in ${{env.SERVICES}} \n
do
aws ecs describe-task-definition
--task-definition hackillinois-api-$service
--query '{ containerDefinitions: taskDefinition.containerDefinitions,family: taskDefinition.family,taskRoleArn: taskDefinition.taskRoleArn,executionRoleArn: taskDefinition.executionRoleArn,networkMode: taskDefinition.networkMode,volumes: taskDefinition.volumes,placementConstraints: taskDefinition.placementConstraints,requiresCompatibilities: taskDefinition.requiresCompatibilities,cpu: taskDefinition.cpu,memory: taskDefinition.memory}' > task_def_$service.json \n
done"
- name: Register new task definition
run:
"for service in ${{env.SERVICES}} \n
do
aws ecs register-task-definition --cli-input-json file://task_def_$service.json \n
done"
- name: Redeploy service with new task definition
run:
"for service in ${{env.SERVICES}} \n
do
aws ecs update-service --cluster hackillinois-api --service hackillinois-api-$service --force-new-deployment --deployment-configuration \"deploymentCircuitBreaker={enable=true,rollback=false}\" --task-definition hackillinois-api-$service \n
done"