6
6
7
7
jobs :
8
8
az-acr-push :
9
- name : " Azure: Docker Container Build & Push"
9
+ name : " Azure: ACR Build & Push"
10
10
runs-on : ubuntu-latest
11
11
environment : dev
12
12
env :
13
13
DOCKERFILE : ${{ vars.DOCKERFILE || 'Dockerfile' }}
14
- AZURE_IMAGE_TAG : latest
15
14
AZURE_CONTAINER_REGISTRY : ${{ secrets.AZURE_CONTAINER_REGISTRY }}
16
15
ACR_LOGIN_USERNAME : ${{ secrets.ACR_LOGIN_USERNAME }}
17
16
ACR_LOGIN_PASSWORD : ${{ secrets.ACR_LOGIN_PASSWORD }}
17
+ strategy :
18
+ matrix :
19
+ platform : [amd64, arm64]
18
20
steps :
19
21
- name : Checkout repository
20
22
uses : actions/checkout@v4
21
-
23
+ - name : Set up Docker Buildx
24
+ uses : docker/setup-buildx-action@v3
22
25
- name : Log into registry
23
26
uses : docker/login-action@v3
24
27
with :
25
28
registry : " ${{ env.AZURE_CONTAINER_REGISTRY }}"
26
29
username : " ${{ env.ACR_LOGIN_USERNAME }}"
27
30
password : " ${{ env.ACR_LOGIN_PASSWORD }}"
28
31
29
- - name : Build & Push - Static Image Tag
32
+ - name : Build & Push
33
+ uses : docker/build-push-action@v5
34
+ with :
35
+ cache-from : type=gha
36
+ cache-to : type=gha,mode=max
37
+ file : ${{ env.DOCKERFILE }}
38
+ tags : ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}
39
+ push : true
40
+ build-args : |
41
+ platform=linux/${{ matrix.platform}}
42
+
43
+ - name : Build & Push - Replace branch
44
+ if : ${{ github.ref != github.repository.default_branch }}
30
45
uses : docker/build-push-action@v5
31
46
with :
47
+ cache-from : type=gha
48
+ cache-to : type=gha,mode=max
32
49
file : ${{ env.DOCKERFILE }}
33
- tags : ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ env.AZURE_IMAGE_TAG }}
50
+ tags : ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}-${{ github.ref_name }}
34
51
push : true
35
52
build-args : |
36
- platform=linux/amd64
53
+ platform=linux/${{ matrix.platform}}
0 commit comments