mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
✨ Support new default branch
See https://github.com/github/renaming#on-october-1-2020-newly-created-repositories-will-default-to-main
This commit is contained in:
@@ -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() {
|
||||
|
||||
14
test.bats
14
test.bats
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user