aboutsummaryrefslogtreecommitdiffhomepage
path: root/files
diff options
context:
space:
mode:
authorpaulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com>2020-06-17 15:10:45 +0200
committerGitHub <noreply@github.com>2020-06-17 15:10:45 +0200
commitd5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6 (patch)
treeda182d67325ec1b8ce02a600e6c458229772eece /files
parent5816bb884149309b6cfcf438feab7265a14d4c0b (diff)
parentb89d0540672614a5d93da43b317015c3ae8554be (diff)
downloadansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.tar.gz
ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.tar.zst
ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.zip
Merge pull request #63 from paulrbr-fl/upgrade-clever-cliv2.5
deploy: remove custom polling script now that the CLI does it for us
Diffstat (limited to 'files')
-rwxr-xr-xfiles/clever-wait-deploy.sh96
1 files changed, 0 insertions, 96 deletions
diff --git a/files/clever-wait-deploy.sh b/files/clever-wait-deploy.sh
deleted file mode 100755
index a95c96f..0000000
--- a/files/clever-wait-deploy.sh
+++ /dev/null
@@ -1,96 +0,0 @@
1#!/usr/bin/env bash
2
3set -ueo pipefail
4
5VERBOSE=${VERBOSE:-}
6lastCleverActivity=""
7timeout=2300 # 100 seconds less than the Ansible tasks' timeout
8startTime=$(date +%s)
9
10function cleverActivity {
11 lastCleverActivity=$(clever activity)
12}
13
14function ensure {
15 local lastReturnCode="$?"
16
17 VERBOSE=true
18 verbose
19
20 if isNotTimeout
21 then
22 if [ "$lastReturnCode" == "0" ]
23 then
24 echo "✓ Deployment done."
25 else
26 echo "✗ Deployment failed!"
27 fi
28 else
29 echo "⁈ Deployment timeout... Please check clever logs"
30 exit 1
31 fi
32}
33
34function isNotTimeout {
35 [ $(($(date +%s) - startTime)) -lt $timeout ]
36}
37
38trap ensure EXIT ERR
39
40function deploying {
41 checkStatus "$1" "IN PROGRESS"
42}
43
44function deployed {
45 checkStatus "$1" "OK"
46}
47
48function inactive {
49 checkStatus "$1" "" "-v"
50}
51
52function checkStatus {
53 local commit="$1"
54 local status="$2"
55
56 cleverActivity
57 echo "${lastCleverActivity}" | tail -n1 | grep ${3:+ "${3}"} -q -E "${status}.*DEPLOY.*${commit}"
58}
59
60function verbose {
61 if [ -n "${VERBOSE}" ]; then
62 echo -e "\\nLast clever activity:"
63 echo -e "${lastCleverActivity}\\n"
64 fi
65}
66
67function check {
68 local commit="$1"
69 local samplingTime=5
70
71 echo "️▫ Waiting for deployment to start..."
72 while inactive "$commit" && isNotTimeout
73 do
74 verbose
75 sleep $samplingTime
76 done
77
78 # Wait for completion
79 echo "▪ Deployment in progress..."
80 while deploying "$commit" && isNotTimeout
81 do
82 verbose
83 sleep $samplingTime
84 done
85
86 deployed "$commit"
87}
88
89function getHeadRev {
90 local chdir="$1/.git"
91
92 git --git-dir="$chdir" rev-parse HEAD
93}
94
95workdir="$(pwd)"
96check "$(getHeadRev "${workdir}")"