This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
80 lines (72 loc) · 3.84 KB
/
staging-deploy-qrcode.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
name: Deploy QR code app to Staging
on:
push:
branches: [main]
jobs:
deploy-qrcode-service:
runs-on: ubuntu-latest
steps:
- name: Wait for container to be built and pushed
# v1.0.0 of this action as of Jan 28 2021
uses: fountainhead/action-wait-for-check@4699210ccc66e2a13260803fadbb77085421b891
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: push-staging
ref: ${{ github.sha }}
- name: Checkout
if: steps.wait-for-build.outputs.conclusion == 'success'
uses: actions/checkout@v2
- name: Configure AWS credentials
# v1 as of Jan 28 2021
uses: aws-actions/configure-aws-credentials@51e2d042f8c5cf77f151685c9338e989dc0b8fc8
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1
- name: Login to Amazon ECR
id: login-ecr
# v1 as of Jan 28 2021
uses: aws-actions/amazon-ecr-login@b9c809dc38d74cd0fde3c13cc4fe4ac72ebecdae
- name: Get Cluster Name
id: cluster
run: |
echo "##[set-output name=name;]$(aws ecs list-clusters | jq -r '.clusterArns[0]' | cut -f 2 -d "/" )"
- name: Download QR Code task definition
id: download-taskdef-qrcode
run: |
aws ecs describe-task-definition --task-definition qrcode_staging --query taskDefinition > task-definition-qrcode.json
echo "##[set-output name=container_name;]$(jq -r '.containerDefinitions[0].name' task-definition-qrcode.json)"
- name: Render image for QR Code service
id: taskdef-qrcode
# v1.0.10
uses: aws-actions/amazon-ecs-render-task-definition@9666dc9d3bf790a3a6a49737b240f17fa599a5f2
with:
task-definition: task-definition-qrcode.json
container-name: ${{ steps.download-taskdef-qrcode.outputs.container_name }}
image: ${{ steps.login-ecr.outputs.registry }}/covid-alert-portal-terraform:${{ github.sha }}
- name: Render appspec for qrcode service
run: |
CONTAINER_PORT=`jq '.containerDefinitions[0].portMappings[0].containerPort' task-definition-qrcode.json`
CONTAINER_NAME=${{ steps.download-taskdef-qrcode.outputs.container_name }}
TASKDEF_ARN=`jq -r '.taskDefinitionArn' task-definition-qrcode.json | cut -f 1-6 -d "/"`
jq --argjson port "$CONTAINER_PORT" --arg cname "$CONTAINER_NAME" --arg taskdefarn "$TASKDEF_ARN" '.Resources[0].TargetService.Properties.TaskDefinition = $taskdefarn | .Resources[0].TargetService.Properties.LoadBalancerInfo.ContainerName = $cname | .Resources[0].TargetService.Properties.LoadBalancerInfo.ContainerPort = $port' config/infrastructure/aws/appspec-template.json > qrcode-appspec.json
- name: Deploy image for QR Code app
timeout-minutes: 10
# v1.4.2
uses: aws-actions/amazon-ecs-deploy-task-definition@c74a8ca2cd0dd04d25f469715e23cb6c2fe0f01a
with:
task-definition: ${{ steps.taskdef-qrcode.outputs.task-definition }}
service: qrcode_staging
cluster: ${{ steps.cluster.outputs.name }}
wait-for-service-stability: true
codedeploy-appspec: ${{ github.workspace }}/qrcode-appspec.json
- name: Run a11y tracker
run: |
curl -s https://api.a11y.cdssandbox.xyz/v1/reports\?recent\=true > /dev/null
sleep 60
json='{"product": "cds-snc/covid-alert-portal-qr-code", "revision": "${{github.sha}}", "urls":["https://register.covid-hcportal.cdssandbox.xyz"], "spider": 1}'
curl -X POST -H 'X-API-KEY: ${{ secrets.A11Y_TRACKER_KEY }}' --data "$json" https://api.a11y.cdssandbox.xyz/v1
- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}