From f1d384c8f5b9b6bf05b8a4818f7244af1c573ab8 Mon Sep 17 00:00:00 2001 From: Philipp Traber Date: Wed, 21 Oct 2026 12:46:07 +0200 Subject: [PATCH] add the option to rename the image pushed to dockerhub --- .gitea/workflows/image.yaml | 17 ++++++++++++----- README.md | 12 ++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/image.yaml b/.gitea/workflows/image.yaml index f2218b6..8693706 100644 --- a/.gitea/workflows/image.yaml +++ b/.gitea/workflows/image.yaml @@ -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 //, and to docker.io// -# when the Docker Hub secrets are passed. +# Images go to //, and to +# docker.io//- (or ) 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 -. type: string required: true + dockerhub-image: + description: Docker Hub repository name, defaults to -. + 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//. + # Optional: with both set, the image is also pushed to + # docker.io//. 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}" diff --git a/README.md b/README.md index 7789970..a569278 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,9 @@ Builds and pushes one image with a uniform tag set from - `registry`: default `registry.traberph.de`. - `project` (required): Harbor project, e.g. `public` or `private`. -- `image` (required): image name, used in Harbor (`//`) and on Docker Hub. +- `image` (required): image name in Harbor (`//`). +- `dockerhub-image`: Docker Hub repository name, default `-`. See + [Docker Hub](#docker-hub). - `context`: default `.`. - `dockerfile`: default `/Dockerfile`. - `platforms`: default `linux/amd64,linux/arm64`. QEMU is set up when an `arm` platform is listed. @@ -92,9 +94,11 @@ tags instead of producing a newer one. ### Docker Hub If `dockerhub-username` and `dockerhub-token` are passed, the image is also pushed with the same -tags to `docker.io//`, e.g. `registry.traberph.de/public/homepage` → -`docker.io/traberph/homepage`. Only pass them for public images: Docker Hub creates new -repositories as public by default. +tags to `docker.io//-`, e.g. +`registry.traberph.de/public/homepage` → `docker.io/traberph/public-homepage`. Docker Hub has no +projects, so the project goes into the name. Set `dockerhub-image` to use another name, e.g. +`dockerhub-image: homepage` → `docker.io/traberph/homepage`. Only pass the secrets for public +images: Docker Hub creates new repositories as public by default. ```yaml secrets: