| 1 | #!/bin/bash | 
| 2 | 
 | 
| 3 | # this file is automatically updated, although the pre-receive hook must be placed manually: | 
| 4 | # 'pre-receive' -> '.git/hooks/pre-receive' | 
| 5 | 
 | 
| 6 | TARGET="/home/ubuntu/joshstock.in/deploy" | 
| 7 | GIT_DIR="/home/ubuntu/joshstock.in/project.git" | 
| 8 | BRANCH="master" | 
| 9 | HTML_OUT="/var/www/html" | 
| 10 | 
 | 
| 11 | while read oldrev newrev ref | 
| 12 | do | 
| 13 |     if [ "$ref" = "refs/heads/$BRANCH" ]; | 
| 14 |     then | 
| 15 |         echo "Ref $ref received. Deploying ${BRANCH} branch to production..." | 
| 16 |         git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH | 
| 17 |         echo "Compiling root HTML" | 
| 18 |         sudo $TARGET/compile.py $HTML_OUT | 
| 19 |         echo "Copying nginx configuration" | 
| 20 |         sudo $TARGET/copynginx prod | 
| 21 |         echo "Installing git pager" | 
| 22 |         sudo $TARGET/installgitpager prod | 
| 23 |     else | 
| 24 |         echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." | 
| 25 |     fi | 
| 26 | done | 
| 27 | 
 |