From df9f7be2264bfc2a2ae2d665655fecf7dacc40a5 Mon Sep 17 00:00:00 2001 From: Hermes Date: Sat, 2 May 2026 19:35:20 -0700 Subject: [PATCH] Add image-prefix with DOCKER_REGISTRY/owner default --- .gitea/actions/docker-build/action.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitea/actions/docker-build/action.yml b/.gitea/actions/docker-build/action.yml index 7bd571e..2cb0812 100644 --- a/.gitea/actions/docker-build/action.yml +++ b/.gitea/actions/docker-build/action.yml @@ -9,8 +9,11 @@ inputs: context: description: Build context path (relative to repo root) default: . + image-prefix: + description: Registry and org prefix (e.g. registry.io/user). Defaults to DOCKER_REGISTRY/owner. + default: ${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }} image-name: - description: Full image name (e.g. registry/image or image) + description: Image name (just the repo part, or full name if image-prefix not used) required: true tags: description: Additional tags as CSV appended to defaults @@ -66,7 +69,8 @@ runs: TAGS="$TAGS,$TAG_NAME" fi - echo "image=${{ inputs.image-name }}" >> $GITHUB_OUTPUT + FULL_IMAGE="${{ inputs.image-prefix }}/${{ inputs.image-name }}" + echo "image=$FULL_IMAGE" >> $GITHUB_OUTPUT echo "tag=$TAG" >> $GITHUB_OUTPUT echo "tags=$TAGS" >> $GITHUB_OUTPUT @@ -88,11 +92,12 @@ runs: done fi + FULL_IMAGE="${{ inputs.image-prefix }}/${{ inputs.image-name }}" set -x docker build \ - --tag "${{ inputs.image-name }}:${{ steps.meta.outputs.tag }}" \ - --tag "${{ inputs.image-name }}:latest" \ - $(for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do echo -n "--tag ${{ inputs.image-name }}:$t "; done) \ + --tag "$FULL_IMAGE:${{ steps.meta.outputs.tag }}" \ + --tag "$FULL_IMAGE:latest" \ + $(for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do echo -n "--tag $FULL_IMAGE:$t "; done) \ --file ${{ inputs.context }}/${{ inputs.dockerfile }} \ $BUILD_ARGS_FLAG \ ${{ inputs.context }} @@ -102,9 +107,10 @@ runs: if: inputs.push == 'true' shell: bash run: | + FULL_IMAGE="${{ inputs.image-prefix }}/${{ inputs.image-name }}" set -x - docker push "${{ inputs.image-name }}:${{ steps.meta.outputs.tag }}" - docker push "${{ inputs.image-name }}:latest" + docker push "$FULL_IMAGE:${{ steps.meta.outputs.tag }}" + docker push "$FULL_IMAGE:latest" for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do - docker push "${{ inputs.image-name }}:$t" + docker push "$FULL_IMAGE:$t" done