Skip to content

Commit

Permalink
fix(ghcr): omit separator in case image is prefixed with dash or slash
Browse files Browse the repository at this point in the history
this allows local pushing to the repo running the action
  • Loading branch information
MikaelElkiaer authored and aexvir committed Jan 11, 2024
1 parent a95ae7d commit 17bff7a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17bff7a

Please sign in to comment.