28
28
- name : Checkout repository
29
29
uses : actions/checkout@v4
30
30
31
+ - name : Identify multi-platform support
32
+ id : platform
33
+ shell : bash
34
+ run : |
35
+ if [ "${{ inputs.image_name }}" = "todo-list" ]; then
36
+ echo "supports_multiplatform=false" >> $GITHUB_OUTPUT
37
+ else
38
+ echo "supports_multiplatform=true" >> $GITHUB_OUTPUT
39
+ fi
40
+
31
41
- name : Pull the latest metadata.json
32
42
if : inputs.image_name == 'awesome-copilot'
33
43
shell : bash
@@ -105,9 +115,11 @@ jobs:
105
115
if : steps.check-dockerfile.outputs.exists == 'true'
106
116
uses : docker/setup-buildx-action@v3
107
117
108
- - name : Build and push Docker image
109
- if : steps.check-dockerfile.outputs.exists == 'true'
110
- id : push
118
+ - name : Build and push Docker image - multi-platform
119
+ if : |
120
+ steps.check-dockerfile.outputs.exists == 'true' &&
121
+ steps.platform.outputs.supports_multiplatform == 'true'
122
+ id : push-multiplatform
111
123
uses : docker/build-push-action@v6
112
124
with :
113
125
platforms : linux/amd64,linux/arm64
@@ -117,10 +129,36 @@ jobs:
117
129
tags : ' ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}:${{ inputs.extension }}'
118
130
labels : ${{ steps.meta.outputs.labels }}
119
131
120
- - name : Generate artifact attestation
121
- if : steps.check-dockerfile.outputs.exists == 'true'
132
+ - name : Generate artifact attestation - multi-platform
133
+ if : |
134
+ steps.check-dockerfile.outputs.exists == 'true' &&
135
+ steps.platform.outputs.supports_multiplatform == 'true'
136
+ uses : actions/attest-build-provenance@v2
137
+ with :
138
+ subject-name : ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}
139
+ subject-digest : ${{ steps.push-multiplatform.outputs.digest }}
140
+ push-to-registry : true
141
+
142
+ - name : Build and push Docker image - amd64 only
143
+ if : |
144
+ steps.check-dockerfile.outputs.exists == 'true' &&
145
+ steps.platform.outputs.supports_multiplatform == 'false'
146
+ id : push-amd64
147
+ uses : docker/build-push-action@v6
148
+ with :
149
+ platforms : linux/amd64
150
+ push : true
151
+ context : ${{ github.workspace }}/${{ inputs.image_name }}
152
+ file : ${{ github.workspace }}/${{ inputs.image_name }}/Dockerfile.${{ inputs.extension }}
153
+ tags : ' ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}:${{ inputs.extension }}'
154
+ labels : ${{ steps.meta.outputs.labels }}
155
+
156
+ - name : Generate artifact attestation - amd64 only
157
+ if : |
158
+ steps.check-dockerfile.outputs.exists == 'true' &&
159
+ steps.platform.outputs.supports_multiplatform == 'false'
122
160
uses : actions/attest-build-provenance@v2
123
161
with :
124
162
subject-name : ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}
125
- subject-digest : ${{ steps.push.outputs.digest }}
163
+ subject-digest : ${{ steps.push-amd64 .outputs.digest }}
126
164
push-to-registry : true
0 commit comments