From 5b9677b4bd09616112913cb1075567cc3f29d5c8 Mon Sep 17 00:00:00 2001 From: Kridsada Thanabulpong Date: Thu, 7 Feb 2019 13:17:57 +0700 Subject: [PATCH] Fix Docker push (#788) --- .circleci/config.yml | 21 +++++++++++++-------- docker-gen.sh | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 08bc3994f..0d90f60d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -350,6 +350,9 @@ jobs: name: Publishing Docker image command: | set -xe + + mkdir -p ~/.ssh + ssh-keyscan github.com >> ~/.ssh/known_hosts docker load -i ~/caches/docker-layers.tar IMAGE_TAG="" @@ -371,11 +374,13 @@ jobs: esac done - # In case the commit is HEAD of master branch, also tag stable. + # In case the commit is HEAD of latest version branch, also tag stable. if [ -n "$CIRCLE_REPOSITORY_URL" ] && [ -n "$CIRCLE_SHA1" ]; then - _ref="refs/heads/master" - _head="$(git ls-remote "$CIRCLE_REPOSITORY_URL" "$_ref" | awk '{ print $1 }')" - if [ "$CIRCLE_SHA1" = "$_head" ]; then + _stable_head="$( + git ls-remote --heads "$CIRCLE_REPOSITORY_URL" "v*" | + awk '/refs\/heads\/v[0-9]+\.[0-9]+$/ { LH=$1 } END { print LH }')" + + if [ "$CIRCLE_SHA1" = "$_stable_head" ]; then IMAGE_TAG="stable $IMAGE_TAG" fi fi @@ -398,7 +403,7 @@ jobs: fi for tag in $IMAGE_TAG; do - printf "\\033[0;34mPublishing Docker image as %s\\033[0;0m\\n" "$IMAGE_TAG" + printf "\\033[0;34mPublishing Docker image as %s\\033[0;0m\\n" "$tag" docker tag "$IMAGE_NAME" "$IMAGE_NAME:$tag" docker push "$IMAGE_NAME:$tag" done @@ -436,7 +441,7 @@ workflows: branches: ignore: - master - - /^v.*/ + - /^v[0-9]+\.[0-9]+/ - /.*e2e$/ tags: ignore: /^v.*/ @@ -450,10 +455,10 @@ workflows: branches: only: - master - - /^v.*/ + - /^v[0-9]+\.[0-9]+/ - /.*e2e$/ tags: - only: /^v.*/ + only: /^v[0-9]+\.[0-9]+\.[0-9]+/ - test_e2e: requires: - build diff --git a/docker-gen.sh b/docker-gen.sh index 7afe8327f..b64a42a65 100755 --- a/docker-gen.sh +++ b/docker-gen.sh @@ -64,7 +64,7 @@ if [ -z "$IMAGE_NAME" ]; then if [ $DEV_MODE = 1 ]; then IMAGE_NAME="omisegoimages/ewallet-builder:v1.1" else - IMAGE_NAME="omisego/ewallet:v1.1.0" + IMAGE_NAME="omisego/ewallet:1.1.0" fi fi