mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
Remove protocol from custom registry for setting in the name and checking in the name
This commit is contained in:
@@ -8,8 +8,9 @@ function main() {
|
|||||||
sanitize "${INPUT_USERNAME}" "username"
|
sanitize "${INPUT_USERNAME}" "username"
|
||||||
sanitize "${INPUT_PASSWORD}" "password"
|
sanitize "${INPUT_PASSWORD}" "password"
|
||||||
|
|
||||||
if uses "${INPUT_REGISTRY}" && ! isPartOfTheName; then
|
REGISTRY_NO_PROTOCOL=$(echo "${INPUT_REGISTRY}" | sed -e 's/^https:\/\///g')
|
||||||
INPUT_NAME="${INPUT_REGISTRY}/${INPUT_NAME}"
|
if uses "${INPUT_REGISTRY}" && ! isPartOfTheName "${REGISTRY_NO_PROTOCOL}"; then
|
||||||
|
INPUT_NAME="${REGISTRY_NO_PROTOCOL}/${INPUT_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
translateDockerTag
|
translateDockerTag
|
||||||
@@ -51,7 +52,7 @@ function sanitize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isPartOfTheName() {
|
function isPartOfTheName() {
|
||||||
[ $(echo "${INPUT_NAME}" | sed -e "s/${INPUT_REGISTRY}//g") != "${INPUT_NAME}" ]
|
[ $(echo "${INPUT_NAME}" | sed -e "s/${1}//g") != "${INPUT_NAME}" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
function translateDockerTag() {
|
function translateDockerTag() {
|
||||||
|
|||||||
16
test.bats
16
test.bats
@@ -227,6 +227,22 @@ Called /usr/local/bin/docker logout"
|
|||||||
[ "$output" = "$expected" ]
|
[ "$output" = "$expected" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "it pushes to another registry and removes the protocol from the reference" {
|
||||||
|
export INPUT_REGISTRY='https://my.Registry.io'
|
||||||
|
export INPUT_NAME='my/repository'
|
||||||
|
|
||||||
|
run /entrypoint.sh
|
||||||
|
|
||||||
|
local expected="
|
||||||
|
Called /usr/local/bin/docker login -u USERNAME --password-stdin https://my.Registry.io
|
||||||
|
Called /usr/local/bin/docker build -t my.Registry.io/my/repository:latest .
|
||||||
|
Called /usr/local/bin/docker push my.Registry.io/my/repository:latest
|
||||||
|
::set-output name=tag::latest
|
||||||
|
Called /usr/local/bin/docker logout"
|
||||||
|
echo $output
|
||||||
|
[ "$output" = "$expected" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "it caches the image from a former build" {
|
@test "it caches the image from a former build" {
|
||||||
export INPUT_CACHE='true'
|
export INPUT_CACHE='true'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user