#!/bin/bash
echo "[post-receive] Beginning check and deploy script :"
while read oldrev newrev ref
do
    if [[ $ref =~ .*/master$ ]];
    then
	echo "[post-receive] Master ref received. Deploying master branch to production..."
        git --work-tree=/var/www/jovian --git-dir=/home/gituser/StaticJovian.git checkout master -f
    else
	echo "[post-receive] Ref $ref successfully received."
	echo "[post-receive] Doing nothing: only the master branch may be deployed on this server."
    fi
done
echo "[post-receive] End of script."