forked from cds-snc/notification-api
-
Notifications
You must be signed in to change notification settings - Fork 9
191 lines (168 loc) · 7.02 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
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
name: api deploy
on:
workflow_call:
inputs:
environment:
required: true
default: "dev"
type: string
ref:
required: true
default: "main"
type: string
jobs:
run-migrations:
runs-on: ${{ vars.RUNS_ON }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.VAEC_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.VAEC_AWS_SECRET_ACCESS_KEY }}
aws-region: us-gov-west-1
role-to-assume: ${{ secrets.VAEC_DEPLOY_ROLE }}
role-skip-session-tagging: true
role-duration-seconds: 1800
- name: Login to VAEC ECR
id: login-ecr-vaec
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Render migration task definition
id: render
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ./cd/application-deployment/${{ inputs.environment }}/vaec-db-migrations-task-definition.json
container-name: ${{ inputs.environment }}-notification-api-db-migrations
image: ${{ steps.login-ecr-vaec.outputs.registry }}/notification_api:${{ inputs.ref }}
environment-variables: |
DD_VERSION=${{ inputs.ref }}
docker-labels: |
VERSION=${{ inputs.ref }}
- name: Register migration task definition
id: register
run: |
echo "arn=$(aws ecs register-task-definition --cli-input-json file://${{ steps.render.outputs.task-definition}} | jq -r '.taskDefinition.taskDefinitionArn')" >> $GITHUB_OUTPUT
- name: Run migration task
run: |
bash ./scripts/run_ci_migrations.sh -c ${{ inputs.environment }}-notification-cluster -e ${{ inputs.environment }} -t ${{ steps.register.outputs.arn }}
deploy-api:
runs-on: ${{ vars.RUNS_ON }}
needs: [run-migrations]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.VAEC_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.VAEC_AWS_SECRET_ACCESS_KEY }}
aws-region: us-gov-west-1
role-to-assume: ${{ secrets.VAEC_DEPLOY_ROLE }}
role-skip-session-tagging: true
role-duration-seconds: 1800
- name: Login to VAEC ECR
id: login-ecr-vaec
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Render API task definition
id: render-api-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ./cd/application-deployment/${{ inputs.environment }}/vaec-api-task-definition.json
container-name: notification-api
image: ${{ steps.login-ecr-vaec.outputs.registry }}/notification_api:${{ inputs.ref }}
environment-variables: |
DD_VERSION=${{ inputs.ref }}
docker-labels: |
VERSION=${{ inputs.ref }}
- name: Deploy API task definition to Fargate
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.render-api-container.outputs.task-definition }}
service: ${{ inputs.environment }}-notification-api-service
cluster: ${{ inputs.environment }}-notification-cluster
wait-for-service-stability: true
deploy-celery:
runs-on: ${{ vars.RUNS_ON }}
needs: [run-migrations]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.VAEC_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.VAEC_AWS_SECRET_ACCESS_KEY }}
aws-region: us-gov-west-1
role-to-assume: ${{ secrets.VAEC_DEPLOY_ROLE }}
role-skip-session-tagging: true
role-duration-seconds: 1800
- name: Login to VAEC ECR
id: login-ecr-vaec
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Render celery task definition
id: render-celery-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ./cd/application-deployment/${{ inputs.environment }}/vaec-celery-task-definition.json
container-name: notification-celery
image: ${{ steps.login-ecr-vaec.outputs.registry }}/notification_api:${{ inputs.ref }}
environment-variables: |
DD_VERSION=${{ inputs.ref }}
docker-labels: |
VERSION=${{ inputs.ref }}
- name: Deploy celery task definition to Fargate
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.render-celery-container.outputs.task-definition }}
service: ${{ inputs.environment }}-notification-celery-service
cluster: ${{ inputs.environment }}-notification-cluster
wait-for-service-stability: true
deploy-celery-beat:
runs-on: ${{ vars.RUNS_ON }}
needs: [run-migrations]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.VAEC_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.VAEC_AWS_SECRET_ACCESS_KEY }}
aws-region: us-gov-west-1
role-to-assume: ${{ secrets.VAEC_DEPLOY_ROLE }}
role-skip-session-tagging: true
role-duration-seconds: 1800
- name: Login to VAEC ECR
id: login-ecr-vaec
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Render celery beat task definition
id: render-celery-beat-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ./cd/application-deployment/${{ inputs.environment }}/vaec-celery-beat-task-definition.json
container-name: notification-celery-beat
image: ${{ steps.login-ecr-vaec.outputs.registry }}/notification_api:${{ inputs.ref }}
environment-variables: |
DD_VERSION=${{ inputs.ref }}
docker-labels: |
VERSION=${{ inputs.ref }}
- name: Deploy celery beat task definition to Fargate
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.render-celery-beat-container.outputs.task-definition }}
service: ${{ inputs.environment }}-notification-celery-beat-service
cluster: ${{ inputs.environment }}-notification-cluster
wait-for-service-stability: true