Add image-prefix with DOCKER_REGISTRY/owner default

This commit is contained in:
Hermes
2026-05-02 19:35:20 -07:00
parent 2cae5b571c
commit df9f7be226

View File

@@ -9,8 +9,11 @@ inputs:
context: context:
description: Build context path (relative to repo root) description: Build context path (relative to repo root)
default: . 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: 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 required: true
tags: tags:
description: Additional tags as CSV appended to defaults description: Additional tags as CSV appended to defaults
@@ -66,7 +69,8 @@ runs:
TAGS="$TAGS,$TAG_NAME" TAGS="$TAGS,$TAG_NAME"
fi 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 "tag=$TAG" >> $GITHUB_OUTPUT
echo "tags=$TAGS" >> $GITHUB_OUTPUT echo "tags=$TAGS" >> $GITHUB_OUTPUT
@@ -88,11 +92,12 @@ runs:
done done
fi fi
FULL_IMAGE="${{ inputs.image-prefix }}/${{ inputs.image-name }}"
set -x set -x
docker build \ docker build \
--tag "${{ inputs.image-name }}:${{ steps.meta.outputs.tag }}" \ --tag "$FULL_IMAGE:${{ steps.meta.outputs.tag }}" \
--tag "${{ inputs.image-name }}:latest" \ --tag "$FULL_IMAGE:latest" \
$(for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do echo -n "--tag ${{ inputs.image-name }}:$t "; done) \ $(for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do echo -n "--tag $FULL_IMAGE:$t "; done) \
--file ${{ inputs.context }}/${{ inputs.dockerfile }} \ --file ${{ inputs.context }}/${{ inputs.dockerfile }} \
$BUILD_ARGS_FLAG \ $BUILD_ARGS_FLAG \
${{ inputs.context }} ${{ inputs.context }}
@@ -102,9 +107,10 @@ runs:
if: inputs.push == 'true' if: inputs.push == 'true'
shell: bash shell: bash
run: | run: |
FULL_IMAGE="${{ inputs.image-prefix }}/${{ inputs.image-name }}"
set -x set -x
docker push "${{ inputs.image-name }}:${{ steps.meta.outputs.tag }}" docker push "$FULL_IMAGE:${{ steps.meta.outputs.tag }}"
docker push "${{ inputs.image-name }}:latest" docker push "$FULL_IMAGE:latest"
for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do for t in $(echo ${{ steps.meta.outputs.tags }} | tr ',' ' '); do
docker push "${{ inputs.image-name }}:$t" docker push "$FULL_IMAGE:$t"
done done