-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from paulrbr-fl/revert-clever-cli-update
Reverting upgrade of clever-tools CLI
- Loading branch information
Showing
4 changed files
with
82 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash -e | ||
|
||
function deploying { | ||
checkStatus "$1" "IN PROGRESS" | ||
} | ||
|
||
function deployed { | ||
checkStatus "$1" "OK" | ||
} | ||
|
||
function inactive { | ||
local commit="$1" | ||
[[ "$(clever activity | grep "$commit" | grep "DEPLOY" | wc -l)" == "0" ]] | ||
} | ||
|
||
function checkStatus { | ||
local commit="$1" | ||
local status="$2" | ||
[[ "$(clever activity | grep "$commit" | grep "${status}\s\+DEPLOY" | wc -l)" == "1" ]] | ||
} | ||
|
||
function check { | ||
local timeout=600 # 10 minutes | ||
local commit="$1" | ||
local samplingTime=5 | ||
|
||
echo "Waiting for deployment start..." | ||
while inactive "$commit" -a $timeout -gt 0 | ||
do | ||
sleep $samplingTime | ||
let "timeout-=$samplingTime" | ||
done | ||
|
||
# Wait for completion | ||
echo "Deployment in progress..." | ||
while deploying "$commit" -a $timeout -gt 0 | ||
do | ||
sleep $samplingTime | ||
let "timeout-=$samplingTime" | ||
done | ||
|
||
if [ $samplingTime -eq 0 ] | ||
then | ||
echo "Timeout" | ||
fi | ||
|
||
deployed "$commit" | ||
} | ||
|
||
function getHeadRev { | ||
local chdir="$1/.git" | ||
|
||
git --git-dir="$chdir" rev-parse HEAD | ||
} | ||
|
||
check "$(getHeadRev "$@")" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,11 @@ | |
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Deploy to Clever-Cloud | ||
shell: "clever deploy" | ||
- name: Push to Clever-Cloud to trigger deployment | ||
command: "git push --force git+ssh://[email protected].clever-cloud.com/{{ clever_app }}.git HEAD:refs/heads/master" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
environment: | ||
CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
register: clever_deploy | ||
async: 900 # 15 minutes timeout | ||
poll: 30 | ||
register: clever_git_push | ||
ignore_errors: true | ||
tags: | ||
- skip_ansible_lint | ||
|
@@ -42,35 +38,33 @@ | |
args: | ||
chdir: "{{ clever_app_root }}" | ||
when: | ||
- clever_deploy is failed | ||
- clever_deploy.stderr is search("Failed to read git object") | ||
- clever_git_push is failed | ||
- clever_git_push.stderr is search("shallow update not allowed") | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Deploy to Clever-Cloud | ||
shell: "clever deploy" | ||
- name: Push to Clever-Cloud to trigger deployment | ||
command: "git push --force git+ssh://[email protected].clever-cloud.com/{{ clever_app }}.git HEAD:refs/heads/master" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
environment: | ||
CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
when: clever_deploy is failed | ||
register: clever_deploy | ||
async: 900 # 15 minutes timeout | ||
poll: 30 | ||
ignore_errors: true | ||
when: clever_git_push is failed | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Return deployment logs | ||
debug: | ||
var: clever_deploy.stdout | ||
|
||
- name: Return deployment errors | ||
debug: | ||
var: clever_deploy.stderr | ||
when: clever_deploy is failed | ||
- name: Watch deployment status | ||
command: "clever-wait-deploy.sh '{{ clever_app_root }}'" | ||
async: 900 | ||
poll: 0 | ||
register: long_command | ||
environment: | ||
CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
changed_when: False | ||
|
||
- name: Fail on deployment errors | ||
fail: | ||
msg: "The clever deployment failed! Please check logs above." | ||
when: clever_deploy is failed | ||
# Waits up to 15 minutes | ||
- name: Wait for deployment completion | ||
async_status: | ||
jid: "{{ long_command.ansible_job_id }}" | ||
register: job_result | ||
until: job_result.finished | ||
delay: 30 | ||
retries: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ | |
with_items: | ||
- clever-set-domain.sh | ||
- clever-set-drain.sh | ||
- clever-wait-deploy.sh |