From 073c9a9c0ea6b1f7325a0154294ec1aba8800935 Mon Sep 17 00:00:00 2001 From: Lars Gohr Date: Sun, 15 Sep 2019 13:20:39 +0200 Subject: [PATCH] Fix https://github.com/elgohr/Publish-Docker-Github-Action/issues/22 --- entrypoint.sh | 2 +- test.bats | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index c55d705..6032f93 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,7 +16,7 @@ if [ -z "${INPUT_PASSWORD}" ]; then exit 1 fi -BRANCH=$(echo ${GITHUB_REF} | sed -e "s/refs\/heads\///g") +BRANCH=$(echo ${GITHUB_REF} | sed -e "s/refs\/heads\///g" | sed -e "s/\//-/g") if [ "${BRANCH}" = "master" ]; then BRANCH="latest" diff --git a/test.bats b/test.bats index 76ede7a..67f83cb 100755 --- a/test.bats +++ b/test.bats @@ -42,6 +42,19 @@ Called mock with: logout" [ "$output" = "$expected" ] } +@test "it converts dashes in branch to hyphens" { + export GITHUB_REF='refs/heads/myBranch/withDash' + + run /entrypoint.sh + + local expected="Called mock with: login -u USERNAME --password-stdin +Called mock with: build -t my/repository:myBranch-withDash . +Called mock with: push my/repository:myBranch-withDash +Called mock with: logout" + echo $output + [ "$output" = "$expected" ] +} + @test "it pushes tags to latest" { export GITHUB_REF='refs/tags/myRelease'