-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 1.75 KB
/
ecr-push.yaml
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
name: AWS ECR Push
on:
workflow_call:
inputs:
runs-on:
description: 'Agent selection string.'
required: false
default: 'ubuntu-latest'
type: string
aws-assume-role-arn:
description: 'The AWS Role ARN to assume for Terraform operations.'
required: true
type: string
aws-assume-role-region:
description: 'The AWS region to assume IAM in for Terraform operations.'
required: true
type: string
aws-ecr-repository-uri:
description: 'The AWS ECR repository URI.'
required: true
type: string
jobs:
deploy:
name: 'Push to ECR'
runs-on: ${{ inputs.runs-on }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.aws-assume-role-arn }}
aws-region: ${{ inputs.aws-assume-role-region }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.aws-ecr-repository-uri }}
tags: |
type=schedule,pattern=latest
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}