From facc275a703d3bccc320e5577eb3d050f99dff0e Mon Sep 17 00:00:00 2001 From: Clement Delafargue Date: Wed, 24 Jun 2020 11:34:28 +0200 Subject: Don't run `clever deploy` if the app is up-to-date Running `git push` when the remote is up-to-date no-ops (it does not trigger a deployment, but it does not fail either). Running `clever deploy` when the remote is up-to-date triggers a failure. Here, we care about the _end result_ (ie the app is deployed on the correct commit), so no-oping is more appropriate. This behaviour is not baked in `clever-tools`, but I think it should. I opened an issue. This script is a temporary workaround. (at least I hope it's temporary) https://github.com/CleverCloud/clever-tools/issues/422 --- files/clever-deploy.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 files/clever-deploy.sh (limited to 'files') diff --git a/files/clever-deploy.sh b/files/clever-deploy.sh new file mode 100755 index 0000000..c301a89 --- /dev/null +++ b/files/clever-deploy.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +function getHeadRev { + git rev-parse HEAD +} + +target_commit="$(getHeadRev)" +running_commit=$(clever status | grep running | sed 's/^.*Commit: //' | sed 's/)$//') + +if [ "${running_commit}" != "${target_commit}" ]; then + echo "Deploying commit ${target_commit}" + clever deploy --force +else + echo "${target_commit} is already deployed, nothing to do" +fi -- cgit v1.2.3