aboutsummaryrefslogtreecommitdiffhomepage
path: root/files/clever-wait-deploy.sh
diff options
context:
space:
mode:
authorPaul Bonaud <paul.bonaud@fretlink.com>2018-11-21 13:20:56 +0100
committerPaul Bonaud <paul.bonaud@fretlink.com>2018-11-21 13:23:36 +0100
commit8fa0dde4720de58a268af5d0ce8818e7da236655 (patch)
tree7b4a32db2941b920142b40946f98a3dab2e2c144 /files/clever-wait-deploy.sh
parent5485dbc4db3e141673457475bcda5fc88057739f (diff)
downloadansible-clever-8fa0dde4720de58a268af5d0ce8818e7da236655.tar.gz
ansible-clever-8fa0dde4720de58a268af5d0ce8818e7da236655.tar.zst
ansible-clever-8fa0dde4720de58a268af5d0ce8818e7da236655.zip
deploy_task: Update clever CLI tools and use it instead of git push
Updating to latest version of 1.1.1 helps to have a stable `clever deploy` command. This commit relies on the output of the command instead of manually pooling the results with `clever activity` command.
Diffstat (limited to 'files/clever-wait-deploy.sh')
-rwxr-xr-xfiles/clever-wait-deploy.sh56
1 files changed, 0 insertions, 56 deletions
diff --git a/files/clever-wait-deploy.sh b/files/clever-wait-deploy.sh
deleted file mode 100755
index e0bbcf1..0000000
--- a/files/clever-wait-deploy.sh
+++ /dev/null
@@ -1,56 +0,0 @@
1#!/bin/bash -e
2
3function deploying {
4 checkStatus "$1" "IN PROGRESS"
5}
6
7function deployed {
8 checkStatus "$1" "OK"
9}
10
11function inactive {
12 local commit="$1"
13 [[ "$(clever activity | grep "$commit" | grep "DEPLOY" | wc -l)" == "0" ]]
14}
15
16function checkStatus {
17 local commit="$1"
18 local status="$2"
19 [[ "$(clever activity | grep "$commit" | grep "${status}\s\+DEPLOY" | wc -l)" == "1" ]]
20}
21
22function check {
23 local timeout=600 # 10 minutes
24 local commit="$1"
25 local samplingTime=5
26
27 echo "Waiting for deployment start..."
28 while inactive "$commit" -a $timeout -gt 0
29 do
30 sleep $samplingTime
31 let "timeout-=$samplingTime"
32 done
33
34 # Wait for completion
35 echo "Deployment in progress..."
36 while deploying "$commit" -a $timeout -gt 0
37 do
38 sleep $samplingTime
39 let "timeout-=$samplingTime"
40 done
41
42 if [ $samplingTime -eq 0 ]
43 then
44 echo "Timeout"
45 fi
46
47 deployed "$commit"
48}
49
50function getHeadRev {
51 local chdir="$1/.git"
52
53 git --git-dir="$chdir" rev-parse HEAD
54}
55
56check "$(getHeadRev "$@")"