Skip to content

Instantly share code, notes, and snippets.

@wilsonsilva
Created September 16, 2014 22:28
Show Gist options
  • Select an option

  • Save wilsonsilva/28246a0c46ec629a30e4 to your computer and use it in GitHub Desktop.

Select an option

Save wilsonsilva/28246a0c46ec629a30e4 to your computer and use it in GitHub Desktop.
post-receive hook for the production and staging environments
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "production" == "$branch" -o "master" == "$branch" ]; then
git --work-tree=/var/www/tracker/production/ checkout -f $branch
cd /var/www/tracker/production/
# Install any packages, if needed
npm install
# Restart the application. Note: the application uid should be 'app'
forever restart app
echo 'Changes pushed to PROD.'
fi
if [ "staging" == "$branch" ]; then
git --work-tree=/var/www/tracker/staging/ checkout -f $branch
cd /var/www/tracker/staging/
# Install any packages, if needed
npm install
# Restart the application. Note: the application uid should be 'app'
forever restart app
echo 'Changes pushed to staging box.'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment