I have set up post-receive hook on my staging server, so whenever I push from dev server a master branch, it updates staging webroot and triggers drush rsync to update live site.
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=/var/www/drupal/ checkout -f $branch
drush rsync --delete --exclude='.htaccess' --exclude='io' --log-file=rsynclog.txt --exclude-files @stage @live
echo 'Changes pushed live.'
fi
if [ "dev" == "$branch" ]; then
git --work-tree=/var/www/drupal/ checkout -f $branch
echo 'Changes pushed to staging.'
fi
done
Or i hoped to do so :) I have ssh keys in place and that is not the problem, what i can see is that it hangs on destroy yes no question. Output after git push origin from dev machine:
Counting objects: 15, done.
Delta compression using up to 4 threads. Compressing objects: 100% (8/8), done. Writing objects: 100% (8/8), 762 bytes, done. Total 8 (delta 5), reused 0 (delta 0)
remote: Already on 'master'
remote: You will destroy data from mydomain.com:/var/www/drupal/ and replace with data from /var/www/drupal// remote: Do you really want to continue? (y/n): Aborting. [cancel]
remote: Changes pushed live. To root@dev:/git/drupal 65abd19..7205946 master -> master
So I would need somehow to tell script that answer is y, or I need a way to avoid that question at all.
Also, I am not pro bash scripter ;) , are those commands being excecuted in line, like in php, so one is not executed before other finishes ? (to make sure changes are propagated on staging webroot first, then rsynced all to live).