From cebb1de2af84a18c2f5a3bf8c9de28dad79e2c5b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 31 Dec 2018 18:59:49 +0000 Subject: [PATCH] fix: add docker login and push tag License: MIT Signed-off-by: Henrique Dias --- wizard.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/wizard.sh b/wizard.sh index 28aa0a6a..f0e799f6 100755 --- a/wizard.sh +++ b/wizard.sh @@ -20,7 +20,8 @@ debugInfo () { } dockerLogin () { - gpg --batch --gen-key <<-EOF + if [ "$CI" == "true" ]; then + gpg --batch --gen-key <<-EOF %echo Generating a standard key Key-Type: DSA Key-Length: 1024 @@ -34,14 +35,17 @@ Expire-Date: 0 %echo done EOF - key=$(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1) - pass init $key + key=$(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1) + pass init $key - if [ "$(command -v docker-credential-pass)" = "" ]; then - docker run --rm -itv /usr/local/bin:/src filebrowser/dev sh -c "cp /go/bin/docker-credential-pass /src" + if [ "$(command -v docker-credential-pass)" = "" ]; then + docker run --rm -itv /usr/local/bin:/src filebrowser/dev sh -c "cp /go/bin/docker-credential-pass /src" + fi + + echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin + else + docker login fi - - echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin } dockerPushLatest () { @@ -51,6 +55,17 @@ dockerPushLatest () { docker logout } +dockerPushTag () { + dockerLogin + + for tag in `echo $(docker images filebrowser/filebrowser* | awk -F ' ' '{print $1 ":" $2}') | cut -d ' ' -f2-`; do + if [ "$tag" = "REPOSITORY:TAG" ]; then break; fi + docker push $tag + done + + docker logout +} + installRice () { if ! [ -x "$(command -v rice)" ]; then go get github.com/GeertJohan/go.rice/rice