Heroku like deployment for your cloud host / VPS

For Be My Eyes I have set up a heroku like deployment environment

Basically I followed this approach:

But there is one problem with the above approach, and that is that I want to be able to push other branches than master to the server. Thats how I push to QA and staging.
A gooogle search found this for me:

Now all I needed was to add a restart

In the post-receive hook, for each repo, I have added the following code


while read oldrev newrev ref
    branch=`echo $ref | cut -d/ -f3`
    GIT_WORK_TREE=/var/www/pathToAPI git checkout -f $branch

touch /var/www/pathToAPI/tmp/restart.txt

With this deployment is as easy as

git push api master

And of course, since I have a git repo behind me, I can rollback pretty easily as well.

Btw if you are instested in helping testing bemyeyes, and you have an iPhone, please do install the beta at http://beta.bemyeyes.org