#!/bin/bash # this file is automatically updated, although the pre-receive hook must be placed manually: # 'pre-receive' -> '.git/hooks/pre-receive' TARGET="/home/ubuntu/joshstock.in/deploy" GIT_DIR="/home/ubuntu/joshstock.in/project.git" BRANCH="master" HTML_OUT="/var/www/html" while read oldrev newrev ref do if [ "$ref" = "refs/heads/$BRANCH" ]; then echo "Ref $ref received. Deploying ${BRANCH} branch to production..." git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH echo "Compiling root HTML" sudo $TARGET/compile.py $HTML_OUT echo "Copying nginx configuration" sudo $TARGET/copynginx prod echo "Installing git pager" sudo $TARGET/installgitpager prod else echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." fi done