Created
April 23, 2015 11:14
-
-
Save aregee/311186902fe84017c7e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read oldrev newrev ref | |
do | |
if [[ $ref =~ .*/master$ ]]; | |
then | |
echo "Master ref received. Deploying master branch to production..." | |
git --work-tree=/home/ubuntu/node-frankly --git-dir=/home/ubuntu/development checkout -f | |
changedfiles=( `git diff-tree --no-commit-id --name-only master` ) | |
if [[ "${changedfiles[*]}" =~ "package.json" ]]; then | |
echo "npm installing" | |
(cd /home/ubuntu/node-frankly && npm install) | |
fi | |
#stopProd | |
(cd /home/ubuntu/node-frankly && source ~/.bashrc && ./bin/stop.sh && ./bin/start.sh && gulp app) | |
#flush cache if new master ref received | |
sudo touch /usr/local/nginx/cache/pagespeed/cache.flush | |
else | |
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment