From b89d0540672614a5d93da43b317015c3ae8554be Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Wed, 17 Jun 2020 11:06:08 +0200 Subject: deploy: remove custom polling script now that the CLI does it for us See recent changes (https://github.com/CleverCloud/clever-tools/pull/415) introduced in 2.5.0+ version of the clever cli tools --- files/clever-wait-deploy.sh | 96 --------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100755 files/clever-wait-deploy.sh (limited to 'files') 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 @@ -#!/usr/bin/env bash - -set -ueo pipefail - -VERBOSE=${VERBOSE:-} -lastCleverActivity="" -timeout=2300 # 100 seconds less than the Ansible tasks' timeout -startTime=$(date +%s) - -function cleverActivity { - lastCleverActivity=$(clever activity) -} - -function ensure { - local lastReturnCode="$?" - - VERBOSE=true - verbose - - if isNotTimeout - then - if [ "$lastReturnCode" == "0" ] - then - echo "✓ Deployment done." - else - echo "✗ Deployment failed!" - fi - else - echo "⁈ Deployment timeout... Please check clever logs" - exit 1 - fi -} - -function isNotTimeout { - [ $(($(date +%s) - startTime)) -lt $timeout ] -} - -trap ensure EXIT ERR - -function deploying { - checkStatus "$1" "IN PROGRESS" -} - -function deployed { - checkStatus "$1" "OK" -} - -function inactive { - checkStatus "$1" "" "-v" -} - -function checkStatus { - local commit="$1" - local status="$2" - - cleverActivity - echo "${lastCleverActivity}" | tail -n1 | grep ${3:+ "${3}"} -q -E "${status}.*DEPLOY.*${commit}" -} - -function verbose { - if [ -n "${VERBOSE}" ]; then - echo -e "\\nLast clever activity:" - echo -e "${lastCleverActivity}\\n" - fi -} - -function check { - local commit="$1" - local samplingTime=5 - - echo "️▫ Waiting for deployment to start..." - while inactive "$commit" && isNotTimeout - do - verbose - sleep $samplingTime - done - - # Wait for completion - echo "▪ Deployment in progress..." - while deploying "$commit" && isNotTimeout - do - verbose - sleep $samplingTime - done - - deployed "$commit" -} - -function getHeadRev { - local chdir="$1/.git" - - git --git-dir="$chdir" rev-parse HEAD -} - -workdir="$(pwd)" -check "$(getHeadRev "${workdir}")" -- cgit v1.2.3