diff --git a/client/hooks/build b/client/hooks/build index 8434e527..86d0c787 100755 --- a/client/hooks/build +++ b/client/hooks/build @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh BUILD_INFO=docker-$(echo $SOURCE_COMMIT | cut -c1-7)-auto echo "Using BUILD_INFO=$BUILD_INFO" docker build --build-arg BUILD_INFO=$BUILD_INFO -f $DOCKERFILE_PATH -t $IMAGE_NAME . diff --git a/client/hooks/post_push b/client/hooks/post_push new file mode 100755 index 00000000..74c19dd2 --- /dev/null +++ b/client/hooks/post_push @@ -0,0 +1,19 @@ +#!/bin/sh + +add_tag() { + echo "Also tagging image as ${DOCKER_REPO}:${1}" + docker tag $IMAGE_NAME $DOCKER_REPO:$1 + docker push $DOCKER_REPO:$1 +} + +CLOSEST_VER=$(git describe --tags --abbrev=0) +CLOSEST_MAJOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f1) +CLOSEST_MINOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f2) + +add_tag "${CLOSEST_MAJOR_VER}-edge" +add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}-edge" + +if git describe --exact-match --abbrev=0 2> /dev/null; then + add_tag "${CLOSEST_MAJOR_VER}" + add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}" +fi \ No newline at end of file diff --git a/server/hooks/post_push b/server/hooks/post_push new file mode 100755 index 00000000..74c19dd2 --- /dev/null +++ b/server/hooks/post_push @@ -0,0 +1,19 @@ +#!/bin/sh + +add_tag() { + echo "Also tagging image as ${DOCKER_REPO}:${1}" + docker tag $IMAGE_NAME $DOCKER_REPO:$1 + docker push $DOCKER_REPO:$1 +} + +CLOSEST_VER=$(git describe --tags --abbrev=0) +CLOSEST_MAJOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f1) +CLOSEST_MINOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f2) + +add_tag "${CLOSEST_MAJOR_VER}-edge" +add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}-edge" + +if git describe --exact-match --abbrev=0 2> /dev/null; then + add_tag "${CLOSEST_MAJOR_VER}" + add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}" +fi \ No newline at end of file