summaryrefslogtreecommitdiff
path: root/client/hooks/post_push
diff options
context:
space:
mode:
authorShyam Sunder <sgsunder1@gmail.com>2019-09-28 16:49:01 -0400
committerShyam Sunder <sgsunder1@gmail.com>2019-09-28 19:28:17 -0400
commit2af304b84441ad090ffc20568384e2426dbdb148 (patch)
tree6268cd7933b60668dcc3e26bcf815f6224f2a1a1 /client/hooks/post_push
parent0c05330cfc634a37938ffe28e7c60da2a7935952 (diff)
docker: add hooks to autotag images
Diffstat (limited to 'client/hooks/post_push')
-rwxr-xr-xclient/hooks/post_push19
1 files changed, 19 insertions, 0 deletions
diff --git a/client/hooks/post_push b/client/hooks/post_push
new file mode 100755
index 0000000..74c19dd
--- /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