mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
committed by
GitHub
parent
5e568ddac4
commit
f7aca2fea7
@@ -9,10 +9,12 @@ main() {
|
||||
echo "::add-mask::${INPUT_PASSWORD}"
|
||||
set -x
|
||||
fi
|
||||
|
||||
|
||||
sanitize "${INPUT_NAME}" "name"
|
||||
sanitize "${INPUT_USERNAME}" "username"
|
||||
sanitize "${INPUT_PASSWORD}" "password"
|
||||
if ! usesBoolean "${INPUT_NO_PUSH}"; then
|
||||
sanitize "${INPUT_USERNAME}" "username"
|
||||
sanitize "${INPUT_PASSWORD}" "password"
|
||||
fi
|
||||
|
||||
registryToLower
|
||||
nameToLower
|
||||
@@ -24,7 +26,7 @@ main() {
|
||||
|
||||
if uses "${INPUT_TAGS}"; then
|
||||
TAGS=$(echo "${INPUT_TAGS}" | sed "s/,/ /g")
|
||||
else
|
||||
else
|
||||
translateDockerTag
|
||||
fi
|
||||
|
||||
@@ -32,7 +34,9 @@ main() {
|
||||
changeWorkingDirectory
|
||||
fi
|
||||
|
||||
echo "${INPUT_PASSWORD}" | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY}
|
||||
if uses "${INPUT_USERNAME}" && uses "${INPUT_PASSWORD}"; then
|
||||
echo "${INPUT_PASSWORD}" | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY}
|
||||
fi
|
||||
|
||||
FIRST_TAG=$(echo "${TAGS}" | cut -d ' ' -f1)
|
||||
DOCKERNAME="${INPUT_NAME}:${FIRST_TAG}"
|
||||
@@ -56,9 +60,11 @@ main() {
|
||||
fi
|
||||
|
||||
build
|
||||
|
||||
|
||||
if usesBoolean "${INPUT_NO_PUSH}"; then
|
||||
docker logout
|
||||
if uses "${INPUT_USERNAME}" && uses "${INPUT_PASSWORD}"; then
|
||||
docker logout
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
12
test.bats
12
test.bats
@@ -627,6 +627,18 @@ teardown() {
|
||||
/usr/local/bin/docker logout"
|
||||
}
|
||||
|
||||
@test "it can be used for building without login" {
|
||||
export GITHUB_REF='refs/heads/master'
|
||||
export INPUT_NO_PUSH='true'
|
||||
export INPUT_USERNAME=''
|
||||
|
||||
run /entrypoint.sh
|
||||
|
||||
expectStdOutIs ""
|
||||
|
||||
expectMockCalledIs "/usr/local/bin/docker build -t my/repository:latest ."
|
||||
}
|
||||
|
||||
@test "it can change the default branch" {
|
||||
export GITHUB_REF='refs/heads/trunk'
|
||||
export INPUT_DEFAULT_BRANCH='trunk'
|
||||
|
||||
Reference in New Issue
Block a user