Skip to content

Commit

Permalink
✨ Support new default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
elgohr committed Sep 20, 2020
1 parent 5265d00 commit b1253b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 14 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit b1253b2

Please sign in to comment.