11name : ' Docker Build and Push'
2- description : ' Build and optionally push a docker image to ACR'
2+ description : ' Build and optionally push a docker image to ACR with multi-architecture support '
33inputs :
44 images :
55 description : ' Name of images to build'
@@ -11,11 +11,11 @@ inputs:
1111 description : ' Password to use when logging into ACR'
1212 required : true
1313 acr-registry-url :
14- description : ' The url of the ACR registry to fetch credentials from. This should matchup with the image names. '
14+ description : ' The url of the ACR registry to fetch credentials from'
1515 required : false
1616 default : ' tignis.azurecr.io'
1717 pip-extra-index-url :
18- description : ' The PIP_EXTRA_INDEX_URL to include as a secret in the docker build. Required to pull private pip packages. '
18+ description : ' The PIP_EXTRA_INDEX_URL to include as a secret'
1919 required : true
2020 push :
2121 description : ' Also push the image to the remote repository'
@@ -32,19 +32,37 @@ inputs:
3232 platforms :
3333 description : ' Comma separated list of platforms to use for docker build'
3434 required : false
35- default : ' linux/amd64,linux/arm64 '
36- tag-prefix :
37- description : ' Prefix to add to generated docker tag '
35+ default : ' linux/amd64'
36+ multi-arch :
37+ description : ' Enable multi-architecture support with manifest creation '
3838 required : false
39- default : ' '
39+ default : ' false'
40+ runner-architecture :
41+ description : ' Architecture of the current runner (for multi-arch builds)'
42+ required : false
43+ default : ' amd64'
44+ create-manifest :
45+ description : ' Create and push a multi-arch manifest (only for multi-arch coordinator)'
46+ required : false
47+ default : ' false'
48+ architecture-tags :
49+ description : ' JSON string with architecture-specific image tags (for manifest creation)'
50+ required : false
51+ default : ' {}'
4052 GITHUB_TOKEN :
41- description : ' Github token of the repository (automatically created by Github) '
53+ description : ' Github token of the repository'
4254 default : ${{ github.token }}
4355 required : false
4456outputs :
45- tag : # id of output
46- description : ' Tag used for the docker image'
57+ tag :
58+ description : ' Full tag used for the docker image'
4759 value : ${{ steps.meta.outputs.tags }}
60+ arch-tag :
61+ description : ' Architecture-specific tag for multi-arch builds'
62+ value : ${{ steps.arch-tag.outputs.tag }}
63+ digests :
64+ description : ' Image digests for manifest creation'
65+ value : ${{ steps.docker_build.outputs.digest }}
4866runs :
4967 using : " composite"
5068 steps :
@@ -118,3 +136,32 @@ runs:
118136 COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
119137
120138 curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"${COMMENT}\"}"
139+ - name : Set architecture tag
140+ id : arch-tag
141+ if : ${{ inputs.multi-arch == 'true' }}
142+ shell : bash
143+ run : |
144+ FULL_TAG="${{ steps.meta.outputs.tags }}"
145+ ARCH="${{ inputs.runner-architecture }}"
146+ echo "tag=${FULL_TAG}-${ARCH}" >> $GITHUB_OUTPUT
147+ - name : Create multi-architecture manifest
148+ if : ${{ inputs.create-manifest == 'true' }}
149+ shell : bash
150+ run : |
151+ # Parse the architecture tags JSON
152+ ARCH_TAGS='${{ inputs.architecture-tags }}'
153+ BASE_IMAGE=$(echo "${{ steps.meta.outputs.tags }}" | cut -d ':' -f 1)
154+ BASE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | cut -d ':' -f 2)
155+
156+ # Create manifest command with all architectures
157+ MANIFEST_CMD="docker manifest create ${BASE_IMAGE}:${BASE_TAG}"
158+
159+ # Add each architecture-specific image to the manifest
160+ for ARCH_TAG in $(echo $ARCH_TAGS | jq -r 'keys[]'); do
161+ DIGEST=$(echo $ARCH_TAGS | jq -r ".[\"$ARCH_TAG\"]")
162+ MANIFEST_CMD="$MANIFEST_CMD ${BASE_IMAGE}@${DIGEST}"
163+ done
164+
165+ # Execute the manifest commands
166+ eval $MANIFEST_CMD
167+ docker manifest push ${BASE_IMAGE}:${BASE_TAG}
0 commit comments