Skip to content

Commit faaf6e4

Browse files
committed
Add optional image_name input to docker-build workflow
Allows overriding the default repo name in REGISTRY_PREFIX. Useful for forks where the deployed image name should differ from the repository name (e.g., core-geonetwork → metaspace).
1 parent dfe06ea commit faaf6e4

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/docker-build.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
description: 'Bake target(s) to build'
1818
type: string
1919
default: default
20+
image_name:
21+
description: 'Image name in registry (defaults to repo name)'
22+
type: string
23+
default: ''
2024
platforms:
2125
description: 'Target platforms (comma-separated)'
2226
type: string
@@ -80,12 +84,20 @@ jobs:
8084
# Build ID matches Bitbucket convention: build_number-commit_sha
8185
BUILD_ID="${{ github.run_number }}-${GITHUB_SHA}"
8286
REPO_NAME="${{ github.event.repository.name }}"
83-
REGISTRY_PREFIX="${{ inputs.registry_host }}/docker/${{ inputs.image_namespace }}/${REPO_NAME}"
87+
88+
# Use custom image_name if provided, otherwise default to repo name
89+
IMAGE_NAME="${{ inputs.image_name }}"
90+
if [[ -z "$IMAGE_NAME" ]]; then
91+
IMAGE_NAME="${REPO_NAME}"
92+
fi
93+
94+
REGISTRY_PREFIX="${{ inputs.registry_host }}/docker/${{ inputs.image_namespace }}/${IMAGE_NAME}"
8495
8596
echo "build_id=${BUILD_ID}" >> $GITHUB_OUTPUT
8697
echo "image_tag=${BUILD_ID}" >> $GITHUB_OUTPUT
8798
echo "registry_prefix=${REGISTRY_PREFIX}" >> $GITHUB_OUTPUT
8899
echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT
100+
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
89101
90102
# For bake file interpolation
91103
echo "REGISTRY_PREFIX=${REGISTRY_PREFIX}" >> $GITHUB_ENV

0 commit comments

Comments
 (0)