@@ -22,20 +22,24 @@ jobs:
22
22
strategy :
23
23
fail-fast : false
24
24
matrix :
25
- os : [ubuntu-24.04, ubuntu-24.04-arm]
25
+ os : [{name: ubuntu-24.04, arch: amd64}, {name: ubuntu-24.04-arm, arch: arm64} ]
26
26
27
27
permissions :
28
28
contents : read
29
29
packages : write
30
- attestations : write
31
30
id-token : write
32
31
33
- runs-on : ${{ matrix.os }}
32
+ runs-on : ${{ matrix.os.name }}
34
33
needs : [ tests ]
35
34
steps :
36
35
- name : Checkout repository
37
36
uses : actions/checkout@v4
38
37
38
+ - name : Prepare
39
+ run : |
40
+ platform=linux/${{ matrix.os.arch }}
41
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
42
+
39
43
- name : Log in to the Container registry
40
44
uses : docker/login-action@v3
41
45
with :
@@ -53,18 +57,75 @@ jobs:
53
57
uses : docker/setup-buildx-action@v3
54
58
55
59
- name : Build and push Docker image
56
- id : push
60
+ id : build
57
61
uses : docker/build-push-action@v6
58
62
with :
59
63
context : .
60
64
push : true
61
65
provenance : false
62
- tags : ${{ steps.meta.outputs.tags }}
66
+ platforms : linux/${{ matrix.os.arch }}
67
+ tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
63
68
labels : ${{ steps.meta.outputs.labels }}
69
+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
70
+
71
+ - name : Export digest
72
+ run : |
73
+ mkdir -p ${{ runner.temp }}/digests
74
+ digest="${{ steps.build.outputs.digest }}"
75
+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
76
+ ls -lah ${{ runner.temp }}/digests/
77
+
78
+ - name : Upload digest
79
+ uses : actions/upload-artifact@v4
80
+ with :
81
+ name : digests-${{ env.PLATFORM_PAIR }}
82
+ path : ${{ runner.temp }}/digests/*
83
+ if-no-files-found : error
84
+ retention-days : 1
85
+
86
+ manifests :
87
+ permissions :
88
+ contents : read
89
+ packages : write
90
+ id-token : write
91
+
92
+ runs-on : ubuntu-latest
93
+ needs : [ docker ]
94
+ steps :
95
+ - name : Download digests
96
+ uses : actions/download-artifact@v4
97
+ with :
98
+ path : ${{ runner.temp }}/digests
99
+ pattern : digests-*
100
+ merge-multiple : true
101
+
102
+ - name : Log in to the Container registry
103
+ uses : docker/login-action@v3
104
+ with :
105
+ registry : ${{ env.REGISTRY }}
106
+ username : ${{ github.actor }}
107
+ password : ${{ secrets.GITHUB_TOKEN }}
108
+
109
+ - name : Set up Docker Buildx
110
+ uses : docker/setup-buildx-action@v3
64
111
65
- - name : Generate artifact attestation
66
- uses : actions/attest-build-provenance@v2
112
+ - name : Docker meta
113
+ id : meta
114
+ uses : docker/metadata-action@v5
67
115
with :
68
- subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
69
- subject-digest : ${{ steps.push.outputs.digest }}
70
- push-to-registry : true
116
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
117
+ tags : |
118
+ type=ref,event=branch
119
+ type=ref,event=pr
120
+ type=semver,pattern={{version}}
121
+ type=semver,pattern={{major}}.{{minor}}
122
+
123
+ - name : Create manifest list and push
124
+ working-directory : ${{ runner.temp }}/digests
125
+ run : |
126
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
127
+ $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
128
+
129
+ - name : Inspect image
130
+ run : |
131
+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
0 commit comments