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
--- /dev/null
+#!/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
changed_when: false
- name: Deploy to Clever-Cloud
- shell: "clever deploy --force"
+ command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-deploy.sh"
args:
chdir: "{{ clever_app_root }}"
environment:
dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}/{{ item }}"
mode: 0755
with_items:
+ - clever-deploy.sh
- clever-set-domain.sh
- clever-set-drain.sh
- clever-set-scalability.sh