From c3e2ff5e0f31c61eae330a1a41d7a8a83435d9bd Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Thu, 6 Aug 2020 11:44:26 +0200 Subject: deploy: try to restart the app when the CLI asks to do it In some cases (rollback or deployment errored on clever side), clever-tools will fail when calling `clever deploy` because it thinks the currently being deployed commit is already deployed. However in some cases the git pushed commit is not the currently running commit. Leading to a failure in our deployment process. The proposed solution from the clever tools error is to launch `clever restart`. Until we wait for https://github.com/CleverCloud/clever-tools/issues/422 to be fixed, let's do what the error message say: try to restart in case of a deployment failure. --- tests/fake.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/fake.sh') diff --git a/tests/fake.sh b/tests/fake.sh index 65ff819..776907b 100755 --- a/tests/fake.sh +++ b/tests/fake.sh @@ -3,6 +3,9 @@ binary="${0/*\/}" localCommit="${PRETEND_LOCAL_COMMIT:-aaa000aaa000aaa000aaa000aaa000aaa000aaa0}" remoteCommit="${PRETEND_REMOTE_COMMIT:-bbb000bbb000bbb000bbb000bbb000bbb000bbb0}" +uptodateDeployment="${DEPLOY_UP_TO_DATE_APP:-}" + +echo "${1}" >> "${binary}-commands" if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then echo "2.6.1" @@ -10,10 +13,17 @@ elif [ "${binary}" = "clever" ] && [ "${1}" = "activity" ]; then echo "2020-02-02T20:20:02+02:00 OK DEPLOY ${remoteCommit} Git" elif [ "${binary}" = "clever" ] && [ "${1}" = "status" ]; then echo "test-app: running (1*pico, Commit: ${remoteCommit})" +elif [ "${binary}" = "clever" ] && [ "${1}" = "deploy" ]; then + if [ -z "${uptodateDeployment}" ]; then + echo "Clever deploy done." + else + # Mimic the current behavior until https://github.com/CleverCloud/clever-tools/issues/422 is solved + >&2 echo "The clever-cloud application is up-to-date. Try this command to restart the application:" + >&2 echo " clever restart" + exit 1 + fi elif [ "${binary}" = "git" ]; then echo "${localCommit}" else echo "${binary} called with arguments: ${*}" fi - -echo "${1}" >> "${binary}-commands" -- cgit v1.2.3