-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (50 loc) · 1.67 KB
/
build-and-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
name: Push image to to ECR
on:
push:
branches:
- 'main'
paths:
- 'operator/**'
- 'resolver/**'
permissions:
id-token: write
contents: read
jobs:
build:
name: Build and Push Docker Images
runs-on: ubuntu-latest
strategy:
matrix:
include:
- directory: operator
repository: elasti-operator
- directory: resolver
repository: elasti-resolver
steps:
- name: Checkoutout code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PUBLIC_ECR_IAM_ROLE_ARN }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REGISTRY_ALIAS: truefoundrycloud
REPOSITORY: ${{ matrix.repository }}
IMAGE_TAG: ${{ github.sha }}
with:
file: ${{ matrix.directory }}/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}:buildcache
cache-to: mode=max,image-manifest=true,type=registry,ref=${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}:buildcache