generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (42 loc) · 1.3 KB
/
build.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
name: Build and Push image
on:
workflow_call:
inputs:
ECR_REGION:
required: true
type: string
ECR_REPOSITORY:
required: true
type: string
secrets:
ECR_ROLE_TO_ASSUME:
required: true
jobs:
build-and-push-to-ecr:
name: Build and Push
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- name: Checkout GitHub repository
uses: actions/checkout@v4
- name: Assume role in Cloud Platform
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ECR_ROLE_TO_ASSUME }}
aws-region: ${{ inputs.ECR_REGION }}
- name: Login to container repository
uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
with:
mask-password: true
- name: Build and push a Docker image to the container repository
id: docker-build
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ inputs.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}