Auto-deploy from Github, workaround with cronjob and bash
Hi,
I have figured how to implement an auto-deploy from Github.
First we cloned the Github repo into Cpanel dir
Second an Cronjob run a file "deploy.sh" every minute to update /public_html by copying local repo files into public.
It works, but it have some issues...
Deploy.sh code snippet:
[CODE=bash](cd ${REPO_DIR} && git pull | grep 'Already up to date.') > /dev/null 2>&1
if [[ ${?} == 0 ]]; then
# Verifica se a pasta de destino j" contem uma instala""o v"lida
if [[ -f ${DEPLOY_DIR}/index.php ]]; then
output "Up to date"
exit 0
fi
fi
I had my Cpanel updated, so the code doesn't work as used to. Now it run and update everything always when cron runs. I used to use this line to verify when to run and update /public_html
And now it is bypassing. Any ideas? Thanks!
I had my Cpanel updated, so the code doesn't work as used to. Now it run and update everything always when cron runs. I used to use this line to verify when to run and update /public_html
git pull | grep 'Already up to date.'And now it is bypassing. Any ideas? Thanks!
-
To my knowledge, there is nothing involved with this that would be affected by a cPanel updated. When you say it is bypassing what is the output it gives? What is the output of the following: git version which git git status
Furthermore, where are you defining REPO_DIR and DEPLOY_DIR variables? What happens when you run agit pull
directly from the repo?0 -
I have found the solution, The output from: git pull | grep 'Already up to date.'
When I run from Bash returns 'Already up to date.'. But when I run by CRON the output is 'Already up-to-date.'. (See the hyphens). Wy is that? I have no idea. So, that's it. I have change my code to:git pull | grep 'Already up[ -]to[ -]date.'
And now it is working like it should.0
Please sign in to leave a comment.
Comments
2 comments