From 17bff7af73609de877334100ef0d9339f8f82c4e Mon Sep 17 00:00:00 2001 From: Mikael Elkiaer <2102306+MikaelElkiaer@users.noreply.github.com> Date: Tue, 31 Jan 2023 10:35:34 +0100 Subject: [PATCH] fix(ghcr): omit separator in case image is prefixed with dash or slash this allows local pushing to the repo running the action --- entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0626f1a..484eca2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -36,11 +36,13 @@ ensure "${CONTEXT_PATH}" "path" if [ "$REGISTRY" == "ghcr.io" ]; then IMAGE_NAMESPACE="$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" - export IMAGE="$IMAGE_NAMESPACE/$IMAGE" - export REPOSITORY="$IMAGE_NAMESPACE/$REPOSITORY" + # Set `/` separator, unless image is pre-fixed with dash or slash + [ -n "$REPOSITORY" ] && [[ ! "$REPOSITORY" =~ ^[-/] ]] && SEPARATOR="/" + export IMAGE="$IMAGE_NAMESPACE$SEPARATOR$IMAGE" + export REPOSITORY="$IMAGE_NAMESPACE$SEPARATOR$REPOSITORY" if [ ! -z $IMAGE_LATEST ]; then - export IMAGE_LATEST="$IMAGE_NAMESPACE/$IMAGE_LATEST" + export IMAGE_LATEST="$IMAGE_NAMESPACE$SEPARATOR$IMAGE_LATEST" fi if [ ! -z $INPUT_CACHE_REGISTRY ]; then