Lars Gohr
2020-09-20 19:40:12 +02:00
parent 5265d00add
commit b1253b2edf
2 changed files with 17 additions and 3 deletions

View File

@@ -115,11 +115,11 @@ hasCustomTag() {
}
isOnDefaultBranch() {
local DEFAULT_BRANCH="master"
if uses "${INPUT_DEFAULT_BRANCH}"; then
DEFAULT_BRANCH="${INPUT_DEFAULT_BRANCH}"
[ "${BRANCH}" = "${INPUT_DEFAULT_BRANCH}" ]
else
[ "${BRANCH}" = "master" ] || [ "${BRANCH}" = "main" ]
fi
[ "${BRANCH}" = "${DEFAULT_BRANCH}" ]
}
isGitTag() {

View File

@@ -25,6 +25,20 @@ teardown() {
unset MOCK_ERROR_CONDITION
}
@test "it pushes main branch to latest" {
export GITHUB_REF='refs/heads/main'
run /entrypoint.sh
expectStdOutContains "::set-output name=tag::latest"
expectMockCalledContains "/usr/local/bin/docker login -u USERNAME --password-stdin
/usr/local/bin/docker build -t my/repository:latest .
/usr/local/bin/docker push my/repository:latest
/usr/local/bin/docker inspect --format={{index .RepoDigests 0}} my/repository:latest
/usr/local/bin/docker logout"
}
@test "it pushes master branch to latest" {
export GITHUB_REF='refs/heads/master'