1 | #!/bin/bash |
2 |
|
3 | # this file must be placed manually at '.git/hooks/post-receive' |
4 |
|
5 | TARGET="/home/ubuntu/joshstockin-deploy" |
6 | GIT_DIR="/home/ubuntu/joshstockin.git" |
7 | BRANCH="master" |
8 |
|
9 | while read oldrev newrev ref |
10 | do |
11 | if [ "$ref" = "refs/heads/$BRANCH" ]; |
12 | then |
13 | echo "Ref $ref received. Deploying ${BRANCH} branch to production..." |
14 | mkdir $TARGET |
15 | git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH |
16 | echo "Running deploy script" |
17 | sudo $TARGET/deploy prod |
18 | echo "Removing deploy directory" |
19 | sudo rm -rf $TARGET |
20 | else |
21 | echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." |
22 | fi |
23 | done |
24 |
|