I found out that it's easy to write git hook on python. It's an example of post-receive hook on python. Provided example deploys master and develop branches in different folders (changes in master will be pushed to production website and changes in develop branch will be pushed to qa site)
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#post-receive
import sys
import subprocess
# 1. Read STDIN (Format: "from_commit to_commit branch_name")
(old, new, branch) = sys.stdin.read().split()
# 2. Only deploy if master branch was pushed
if branch == 'refs/heads/master':
subprocess.call('date >> ~/prod-deployment.log', shell=True)
subprocess.call('GIT_WORK_TREE=/home/ft/app.prod git checkout master -f', shell=True)
subprocess.call('cd ../../app.prod;bower update', shell=True)
#3. Only deploy if develop branch was pushed
if branch == 'refs/heads/develop':
subprocess.call('date >> ~/dev-deployment.log', shell=True)
subprocess.call('GIT_WORK_TREE=/home/ft/app.dev git checkout develop -f', shell=True)
subprocess.call('cd ../../app.dev;bower update', shell=True)