11name : ' Docker Build and Push'
2- description : ' Build and optionally push a docker image to ACR with multi-architecture support '
2+ description : ' Build and optionally push a docker image to ACR'
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'
14+ description : ' The url of the ACR registry to fetch credentials from. This should matchup with the image names. '
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'
18+ description : ' The PIP_EXTRA_INDEX_URL to include as a secret in the docker build. Required to pull private pip packages. '
1919 required : true
2020 push :
2121 description : ' Also push the image to the remote repository'
@@ -32,43 +32,22 @@ inputs:
3232 platforms :
3333 description : ' Comma separated list of platforms to use for docker build'
3434 required : false
35- default : ' linux/amd64'
36- multi-arch :
37- description : ' Enable multi-architecture support with manifest creation '
35+ default : ' linux/amd64,linux/arm64 '
36+ tag-prefix :
37+ description : ' Prefix to add to generated docker tag '
3838 required : false
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 : ' {}'
39+ default : ' '
5240 GITHUB_TOKEN :
53- description : ' Github token of the repository'
41+ description : ' Github token of the repository (automatically created by Github) '
5442 default : ${{ github.token }}
5543 required : false
5644outputs :
57- tag :
58- description : ' Full tag used for the docker image'
45+ tag : # id of output
46+ description : ' Tag used for the docker image'
5947 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 }}
6648runs :
6749 using : " composite"
6850 steps :
69- - name : Debug inputs
70- run : echo ${{ inputs.platforms }}
71- shell : bash
7251 - name : Get build info
7352 run : |
7453 echo "DATE=$(date -u +%F)" >> $GITHUB_ENV
@@ -114,14 +93,13 @@ runs:
11493 password : ${{ inputs.acr-password }}
11594 - name : Build and push
11695 id : docker_build
117- if : ${{ inputs.create-manifest != 'true' }} # Skip this step for manifest creation
11896 uses : docker/build-push-action@v6
11997 with :
12098 context : ${{ inputs.docker-build-context }}
12199 push : ${{ inputs.push }}
122100 tags : ${{ steps.meta.outputs.tags }}
123101 labels : ${{ steps.meta.outputs.labels }}
124- platforms : ${{ inputs.platforms }}
102+ platforms : ${{inputs.platforms}}
125103 secrets : |
126104 "pipconf=[global]
127105 extra-index-url = ${{ inputs.pip-extra-index-url }}"
@@ -139,34 +117,4 @@ runs:
139117 GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}
140118 COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
141119
142- curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"${COMMENT}\"}"
143- - name : Set architecture tag
144- id : arch-tag
145- if : ${{ inputs.multi-arch == 'true' }}
146- shell : bash
147- run : |
148- FULL_TAG="${{ steps.meta.outputs.tags }}"
149- ARCH="${{ inputs.runner-architecture }}"
150- echo "tag=${FULL_TAG}-${ARCH}" >> $GITHUB_OUTPUT
151- - name : Create multi-architecture manifest
152- if : ${{ inputs.create-manifest == 'true' }}
153- shell : bash
154- run : |
155- # Parse the architecture tags JSON
156- ARCH_TAGS='${{ inputs.architecture-tags }}'
157- echo "Arch tags: $ARCH_TAGS"
158- BASE_IMAGE=$(echo "${{ steps.meta.outputs.tags }}" | cut -d ':' -f 1)
159- BASE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | cut -d ':' -f 2)
160-
161- # Create manifest command with all architectures
162- MANIFEST_CMD="docker manifest create ${BASE_IMAGE}:${BASE_TAG}"
163-
164- # Add each architecture-specific image to the manifest
165- for ARCH_TAG in $(echo $ARCH_TAGS | jq -r 'keys[]'); do
166- DIGEST=$(echo $ARCH_TAGS | jq -r ".[\"$ARCH_TAG\"]")
167- MANIFEST_CMD="$MANIFEST_CMD ${BASE_IMAGE}@${DIGEST}"
168- done
169- echo "Executing manifest command: $MANIFEST_CMD"
170- # Execute the manifest commands
171- eval $MANIFEST_CMD
172- docker manifest push ${BASE_IMAGE}:${BASE_TAG}
120+ curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"${COMMENT}\"}"
0 commit comments