Skip to content

Commit ac6c4f2

Browse files
authored
Maybe better syntax for calculate docker image with custom tag prefix (#6586)
Allow calculate docker image to work with custom tag prefix by just putting the tag in the docker image name. Old: need custom-tag-prefix input New: can use custom-tag-prefix input, but can also do imagename:tagprefix This makes it easier for some stuff in pytorch/pytorch, where we rely on the convention that an image with the registry at the beginning is the complete image name, and otherwise the foldersha should be added Testing on https://hud.pytorch.org/pytorch/pytorch/commit/e6a9e25ba6ef97810652d1c4af395e71cf08ad9d
1 parent 73c646d commit ac6c4f2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/actions/calculate-docker-image/action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ inputs:
2020
default: ./build.sh
2121
custom-tag-prefix:
2222
description: |
23-
The prefix to use for the docker image tag.
23+
The prefix to use for the docker image tag. You can also just do imagename:customtag
2424
default: ""
2525
working-directory:
2626
description: The working directory where the repo is checked out.
@@ -81,9 +81,14 @@ runs:
8181
echo "docker-tag=${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
8282
echo "docker-image=${DOCKER_IMAGE_NAME}" >> "${GITHUB_OUTPUT}"
8383
else
84+
if [[ "${DOCKER_IMAGE_NAME}" == *:* ]]; then
85+
CUSTOM_TAG_PREFIX=${DOCKER_IMAGE_NAME#*:}
86+
DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME%%:*}
87+
fi
8488
DOCKER_TAG=${CUSTOM_TAG_PREFIX:+${CUSTOM_TAG_PREFIX}-}$(git rev-parse HEAD:"${DOCKER_BUILD_DIR}")
8589
echo "docker-tag=${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
8690
echo "docker-image=${DOCKER_REGISTRY}/${REPO_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
91+
echo "custom-tag-prefix=${CUSTOM_TAG_PREFIX}" >> "${GITHUB_OUTPUT}"
8792
fi
8893
8994
- name: Check if image should be built
@@ -196,7 +201,7 @@ runs:
196201
env:
197202
REPO_NAME: ${{ github.event.repository.name }}
198203
DOCKER_IMAGE: ${{ steps.calculate-image.outputs.docker-image }}
199-
CUSTOM_TAG_PREFIX: ${{ inputs.custom-tag-prefix }}
204+
CUSTOM_TAG_PREFIX: ${{ steps.calculate-image.outputs.custom-tag-prefix }}
200205
DOCKER_REGISTRY: ${{ inputs.docker-registry }}
201206
WORKING_DIRECTORY: ${{ inputs.working-directory }}/${{ inputs.docker-build-dir }}
202207
DOCKER_BUILD_SCRIPT: ${{ inputs.docker-build-script }}

0 commit comments

Comments
 (0)