add the option to rename the image pushed to dockerhub

This commit is contained in:
2026-10-21 12:46:07 +02:00
parent b1403046e5
commit f1d384c8f5
2 changed files with 20 additions and 9 deletions
+12 -5
View File
@@ -11,8 +11,9 @@ name: image
# commit: a repo with several images calls this once per image (the calls run in
# parallel) and all of them get the same tag. Rebuilding a commit re-pushes its tag.
#
# Images go to <registry>/<project>/<image>, and to docker.io/<dockerhub-username>/<image>
# when the Docker Hub secrets are passed.
# Images go to <registry>/<project>/<image>, and to
# docker.io/<dockerhub-username>/<project>-<image> (or <dockerhub-image>) when the Docker Hub
# secrets are passed.
#
# After a push, the compressed size per platform is printed to the log and the job summary.
#
@@ -47,9 +48,13 @@ on:
type: string
required: true
image:
description: Image name, in Harbor and on Docker Hub.
description: Image name in Harbor, and on Docker Hub as <project>-<image>.
type: string
required: true
dockerhub-image:
description: Docker Hub repository name, defaults to <project>-<image>.
type: string
default: ""
context:
type: string
default: "."
@@ -80,7 +85,8 @@ on:
required: false
registry-token:
required: false
# Optional: with both set, the image is also pushed to docker.io/<dockerhub-username>/<image>.
# Optional: with both set, the image is also pushed to
# docker.io/<dockerhub-username>/<dockerhub-image>.
dockerhub-username:
required: false
dockerhub-token:
@@ -108,6 +114,7 @@ jobs:
# Secrets can't be used in `if:` directly, env can.
DOCKERHUB: ${{ secrets.dockerhub-username != '' && secrets.dockerhub-token != '' }}
DOCKERHUB_USERNAME: ${{ secrets.dockerhub-username }}
DOCKERHUB_IMAGE: ${{ inputs.dockerhub-image || format('{0}-{1}', inputs.project, inputs.image) }}
steps:
- uses: actions/checkout@v7
@@ -119,7 +126,7 @@ jobs:
images="${IMAGE}"
if [ "${DOCKERHUB}" = "true" ]; then
images="${images}
docker.io/${DOCKERHUB_USERNAME}/${{ inputs.image }}"
docker.io/${DOCKERHUB_USERNAME}/${DOCKERHUB_IMAGE}"
fi
{
echo "ts=${ts}"