#!/bin/bash TARGET="/var/www/monsite" GIT_DIR="/home/marc/monprojet.git" BRANCH="master" while read oldrev newrev ref do if [[ $ref = refs/heads/$BRANCH ]]; then echo "Ref $ref received. Deploying ${BRANCH} branch to preprod..." git --work-tree=$TARGET --git-dir=$GIT_DIR checkout $BRANCH -f chown www-data:www-data -R $TARGET else echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." fi done