Skip to content

Instantly share code, notes, and snippets.

@aregee
Created April 23, 2015 11:14
Show Gist options
  • Save aregee/311186902fe84017c7e8 to your computer and use it in GitHub Desktop.
Save aregee/311186902fe84017c7e8 to your computer and use it in GitHub Desktop.
#!/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