generated from cds-snc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (42 loc) · 1.56 KB
/
prod-docker-build-push.yml
File metadata and controls
51 lines (42 loc) · 1.56 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
name: "Production — Docker build and push"
on:
release:
types: [published]
env:
AWS_ACCOUNT_ID: ${{ vars.PRODUCTION_AWS_ACCOUNT_ID }}
AWS_REGION: ca-central-1
ECR_REPOSITORY: forms/api
TAG_VERSION: ${{ github.ref_name }}
permissions:
id-token: write
contents: write
security-events: write
jobs:
push-production:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Build Docker image
run: docker build --platform=linux/amd64 --provenance false -t forms/api .
- name: Configure AWS credentials using OIDC
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/forms-api-release
role-session-name: ECRPush
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@a080f59b057d681bf221f98cbdcd9f0defa1a1a9
- name: Tag images
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker tag forms/api $ECR_REGISTRY/$ECR_REPOSITORY:$TAG_VERSION
docker tag forms/api $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: Push images to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$TAG_VERSION
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest