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:
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