1
- name : Deploy to Amazon ECR
1
+ name : Deploy to Amazon ECS
2
2
3
3
on :
4
4
push :
35
35
uses : aws-actions/amazon-ecr-login@v1
36
36
37
37
- name : Dev - Build and deploy to Amazon ECR
38
+ id : build-image-dev
38
39
if : github.ref == 'refs/heads/develop'
39
40
env :
40
41
ECR_REPOSITORY : qppsf/conversion-tool/dev
@@ -47,24 +48,49 @@ jobs:
47
48
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
48
49
docker tag $ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
49
50
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
51
+ echo "::set-output name=image-dev::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
52
+
53
+ - name : Get task definition for dev
54
+ if : github.ref == 'refs/heads/develop' && success()
55
+ run : |
56
+ aws ecs describe-task-definition --task-definition qppsf-conversion-tool-td-dev --query taskDefinition > task-definition.json
57
+
58
+ - name : Fill in image ID for ECS task-definition
59
+ id : task-def-dev
60
+ if : github.ref == 'refs/heads/develop' && success()
61
+ uses : aws-actions/amazon-ecs-render-task-definition@v1
62
+ with :
63
+ task-definition : task-definition.json
64
+ container-name : conversion-tool
65
+ image : ${{ steps.build-image-dev.outputs.image-dev }}
66
+
67
+ - name : Deploy Amazon ECS task definition
68
+ if : github.ref == 'refs/heads/develop' && success()
69
+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
70
+ with :
71
+ task-definition : ${{ steps.task-def-dev.outputs.task-definition }}
72
+ service : conversion-tool-service-dev
73
+ cluster : qppsf-conversion-tool-dev
74
+ wait-for-service-stability : true
50
75
51
76
- name : Dev - Notify slack success
52
77
if : github.ref == 'refs/heads/develop' && success()
53
78
uses : voxmedia/github-action-slack-notify-build@v1
54
79
with :
55
80
channel : p-qpp-sub-alerts
56
- status : Conversion tools - Successful Docker build and AWS ECR deployment
81
+ status : Conversion tools - Successful Docker build and AWS ECS deployment
57
82
color : good
58
83
59
84
- name : Dev - Notify slack fail
60
85
if : github.ref == 'refs/heads/develop' && failure()
61
86
uses : voxmedia/github-action-slack-notify-build@v1
62
87
with :
63
88
channel : p-qpp-sub-alerts
64
- status : Conversion tools - Failed Docker build or AWS ECR deployment
89
+ status : Conversion tools - Failed Docker build or AWS ECS deployment
65
90
color : danger
66
91
67
- - name : Impl - Build and deploy to Amazon ECR
92
+ - name : Impl - Build and deploy to Amazon ECR
93
+ id : build-image-impl
68
94
if : startsWith(github.ref,'refs/heads/release/')
69
95
env :
70
96
ECR_REPOSITORY : qppsf/conversion-tool/impl
@@ -77,24 +103,71 @@ jobs:
77
103
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
78
104
docker tag $ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
79
105
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
106
+ echo "::set-output name=image-impl::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
107
+
108
+ - name : Get task definition for Impl
109
+ if : startsWith(github.ref,'refs/heads/release/') && success()
110
+ run : |
111
+ aws ecs describe-task-definition --task-definition qppsf-conversion-tool-td-impl --query taskDefinition > task-definition.json
112
+
113
+ - name : Fill in image ID for ECS task-definition
114
+ id : task-def-impl
115
+ if : startsWith(github.ref,'refs/heads/release/') && success()
116
+ uses : aws-actions/amazon-ecs-render-task-definition@v1
117
+ with :
118
+ task-definition : task-definition.json
119
+ container-name : conversion-tool
120
+ image : ${{ steps.build-image-impl.outputs.image-impl }}
121
+
122
+ - name : Deploy Amazon ECS task definition
123
+ if : startsWith(github.ref,'refs/heads/release/') && success()
124
+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
125
+ with :
126
+ task-definition : ${{ steps.task-def-impl.outputs.task-definition }}
127
+ service : conversion-tool-service-impl
128
+ cluster : qppsf-conversion-tool-impl
129
+ wait-for-service-stability : true
80
130
81
131
- name : Impl - Notify slack success
82
132
if : startsWith(github.ref,'refs/heads/release/') && success()
83
133
uses : voxmedia/github-action-slack-notify-build@v1
84
134
with :
85
135
channel : p-qpp-sub-alerts
86
- status : Conversion tools - Successful Docker build and AWS ECR deployment
136
+ status : Conversion tools - Successful Docker build and AWS ECS deployment
87
137
color : good
88
138
89
139
- name : Impl - Notify slack fail
90
140
if : startsWith(github.ref,'refs/heads/release/') && failure()
91
141
uses : voxmedia/github-action-slack-notify-build@v1
92
142
with :
93
143
channel : p-qpp-sub-alerts
94
- status : Conversion tools - Failed Docker build or AWS ECR deployment
144
+ status : Conversion tools - Failed Docker build or AWS ECS deployment
95
145
color : danger
96
146
147
+ # OKR Metrics Publish - start
148
+ - name : Get OKR Event Start-Date
149
+ if : github.ref == 'refs/heads/master'
150
+ run : |
151
+ echo "event_start_dt=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
152
+
153
+ - name : Get okr-metrics properties
154
+ if : github.ref == 'refs/heads/master'
155
+ id : read_properties_start
156
+ run : |
157
+ source isg-okr.properties
158
+ echo "conf_pg_id=${confluenceReleasePageId}" >> $GITHUB_ENV
159
+ echo "deployment_type=${deploy_type}" >> $GITHUB_ENV
160
+
161
+ - name : Deployment Pipeline Start - Publish to OKR
162
+ if : github.ref == 'refs/heads/master'
163
+ run : |
164
+ curl -v --location --request POST 'https://api.github.com/repos/cmsGov/qpp-okr/issues' \
165
+ --header 'Authorization: Token ${{ secrets.OKR_AUTH_TOKEN }}'' \
166
+ --header 'Content-Type: application/json' \
167
+ --data-raw '{ "title": "QPPSF Deployment - Conversion Tool", "body": "\r\n```json\r\n{\r\n \"program\": \"QPP\",\r\n \"team\": \"QPPSF\",\r\n \"component\": \"Conversion-Tool\",\r\n \"tier\": \"PROD\",\r\n \"eventTime\": \"${{ env.event_start_dt }}\" ,\r\n \"eventType\": \"start\",\r\n \"confluenceReleasePageId\": \"${{ env.conf_pg_id }}\",\r\n \"releaseType\": \"${{ env.deployment_type }}\",\r\n \"correlationId\": \"GITWORKFLOW\"\r\n}\r\n```\r\nThis issue is created by Github Action","labels": ["deploy"]}'
168
+
97
169
- name : Prod - Build and deploy to Amazon ECR
170
+ id : build-image-prod
98
171
if : github.ref == 'refs/heads/master'
99
172
env :
100
173
ECR_REPOSITORY : qppsf/conversion-tool/prod
@@ -107,24 +180,71 @@ jobs:
107
180
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
108
181
docker tag $ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
109
182
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
183
+ echo "::set-output name=image-prod::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
184
+
185
+ - name : Get task definition for Prod
186
+ if : github.ref == 'refs/heads/master' && success()
187
+ run : |
188
+ aws ecs describe-task-definition --task-definition qppsf-conversion-tool-td-prod --query taskDefinition > task-definition.json
189
+
190
+ - name : Fill in image ID for ECS task-definition
191
+ id : task-def-prod
192
+ if : github.ref == 'refs/heads/master' && success()
193
+ uses : aws-actions/amazon-ecs-render-task-definition@v1
194
+ with :
195
+ task-definition : task-definition.json
196
+ container-name : conversion-tool
197
+ image : ${{ steps.build-image-prod.outputs.image-prod }}
198
+
199
+ - name : Deploy Amazon ECS task definition
200
+ if : github.ref == 'refs/heads/master' && success()
201
+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
202
+ with :
203
+ task-definition : ${{ steps.task-def-prod.outputs.task-definition }}
204
+ service : conversion-tool-service-prod
205
+ cluster : qppsf-conversion-tool-prod
206
+ wait-for-service-stability : true
110
207
111
208
- name : Prod - Notify slack success
112
209
if : github.ref == 'refs/heads/master' && success()
113
210
uses : voxmedia/github-action-slack-notify-build@v1
114
211
with :
115
212
channel : p-qpp-sub-alerts
116
- status : Conversion tools - Successful Docker build and AWS ECR deployment
213
+ status : Conversion tools - Successful Docker build and AWS ECS deployment
117
214
color : good
118
215
119
216
- name : Prod - Notify slack fail
120
217
if : github.ref == 'refs/heads/master' && failure()
121
218
uses : voxmedia/github-action-slack-notify-build@v1
122
219
with :
123
220
channel : p-qpp-sub-alerts
124
- status : Conversion tools - Failed Docker build or AWS ECR deployment
221
+ status : Conversion tools - Failed Docker build or AWS ECS deployment
125
222
color : danger
126
223
224
+ # OKR Metrics Publish - Finish
225
+ - name : Get OKR Event Finish-Date
226
+ if : github.ref == 'refs/heads/master' && success()
227
+ run : |
228
+ echo "event_finish_dt=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
229
+
230
+ - name : Get okr-metrics properties
231
+ if : github.ref == 'refs/heads/master' && success()
232
+ id : read_properties_finish
233
+ run : |
234
+ source isg-okr.properties
235
+ echo "conf_pg_id=${confluenceReleasePageId}" >> $GITHUB_ENV
236
+ echo "deployment_type=${deploy_type}" >> $GITHUB_ENV
237
+
238
+ - name : Deployment Pipeline Finish - Publish to OKR
239
+ if : github.ref == 'refs/heads/master' && success()
240
+ run : |
241
+ curl -v --location --request POST 'https://api.github.com/repos/cmsGov/qpp-okr/issues' \
242
+ --header 'Authorization: Token ${{ secrets.OKR_AUTH_TOKEN }}'' \
243
+ --header 'Content-Type: application/json' \
244
+ --data-raw '{ "title": "QPPSF Deployment - Conversion Tool", "body": "\r\n```json\r\n{\r\n \"program\": \"QPP\",\r\n \"team\": \"QPPSF\",\r\n \"component\": \"Conversion-Tool\",\r\n \"tier\": \"PROD\",\r\n \"eventTime\": \"${{ env.event_finish_dt }}\" ,\r\n \"eventType\": \"finish\",\r\n \"confluenceReleasePageId\": \"${{ env.conf_pg_id }}\",\r\n \"releaseType\": \"${{ env.deployment_type }}\",\r\n \"correlationId\": \"GITWORKFLOW\"\r\n}\r\n```\r\nThis issue is created by Github Action","labels": ["deploy"]}'
245
+
127
246
- name : DevPre - Build and deploy to Amazon ECR
247
+ id : build-image-devpre
128
248
if : github.ref == 'refs/heads/master'
129
249
env :
130
250
ECR_REPOSITORY : qppsf/conversion-tool/devpre
@@ -137,21 +257,45 @@ jobs:
137
257
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
138
258
docker tag $ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
139
259
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
260
+ echo "::set-output name=image-devpre::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
261
+
262
+ - name : Get task definition for DevPre
263
+ if : github.ref == 'refs/heads/master' && success()
264
+ run : |
265
+ aws ecs describe-task-definition --task-definition qppsf-conversion-tool-td-devpre --query taskDefinition > task-definition.json
266
+
267
+ - name : Fill in image ID for ECS task-definition
268
+ id : task-def-devpre
269
+ if : github.ref == 'refs/heads/master' && success()
270
+ uses : aws-actions/amazon-ecs-render-task-definition@v1
271
+ with :
272
+ task-definition : task-definition.json
273
+ container-name : conversion-tool
274
+ image : ${{ steps.build-image-devpre.outputs.image-devpre }}
275
+
276
+ - name : Deploy Amazon ECS task definition
277
+ if : github.ref == 'refs/heads/master' && success()
278
+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
279
+ with :
280
+ task-definition : ${{ steps.task-def-devpre.outputs.task-definition }}
281
+ service : conversion-tool-service-devpre
282
+ cluster : qppsf-conversion-tool-devpre
283
+ wait-for-service-stability : true
140
284
141
285
- name : DevPre - Notify slack success
142
286
if : github.ref == 'refs/heads/master' && success()
143
287
uses : voxmedia/github-action-slack-notify-build@v1
144
288
with :
145
289
channel : p-qpp-sub-alerts
146
- status : Conversion tools - Successful Docker build and AWS ECR deployment
290
+ status : Conversion tools - Successful Docker build and AWS ECS deployment
147
291
color : good
148
292
149
293
- name : DevPre - Notify slack fail
150
294
if : github.ref == 'refs/heads/master' && failure()
151
295
uses : voxmedia/github-action-slack-notify-build@v1
152
296
with :
153
297
channel : p-qpp-sub-alerts
154
- status : Conversion tools - Failed Docker build or AWS ECR deployment
298
+ status : Conversion tools - Failed Docker build or AWS ECS deployment
155
299
color : danger
156
300
157
301
- name : Logout of Amazon ECR
0 commit comments