From 85d8706c5b0f5672025342f70117909177657ff1 Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Fri, 30 Nov 2018 14:38:25 +0100 Subject: Revert "Merge pull request #19 from paulrbr-fl/update-clever-tools" This reverts commit 695ceaa28821660e17a1cf819cffebe1b5d8c7ca, reversing changes made to 5485dbc4db3e141673457475bcda5fc88057739f. --- files/clever-wait-deploy.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 files/clever-wait-deploy.sh (limited to 'files') diff --git a/files/clever-wait-deploy.sh b/files/clever-wait-deploy.sh new file mode 100755 index 0000000..e0bbcf1 --- /dev/null +++ b/files/clever-wait-deploy.sh @@ -0,0 +1,56 @@ +#!/bin/bash -e + +function deploying { + checkStatus "$1" "IN PROGRESS" +} + +function deployed { + checkStatus "$1" "OK" +} + +function inactive { + local commit="$1" + [[ "$(clever activity | grep "$commit" | grep "DEPLOY" | wc -l)" == "0" ]] +} + +function checkStatus { + local commit="$1" + local status="$2" + [[ "$(clever activity | grep "$commit" | grep "${status}\s\+DEPLOY" | wc -l)" == "1" ]] +} + +function check { + local timeout=600 # 10 minutes + local commit="$1" + local samplingTime=5 + + echo "Waiting for deployment start..." + while inactive "$commit" -a $timeout -gt 0 + do + sleep $samplingTime + let "timeout-=$samplingTime" + done + + # Wait for completion + echo "Deployment in progress..." + while deploying "$commit" -a $timeout -gt 0 + do + sleep $samplingTime + let "timeout-=$samplingTime" + done + + if [ $samplingTime -eq 0 ] + then + echo "Timeout" + fi + + deployed "$commit" +} + +function getHeadRev { + local chdir="$1/.git" + + git --git-dir="$chdir" rev-parse HEAD +} + +check "$(getHeadRev "$@")" -- cgit v1.2.3