Skip to content

Instantly share code, notes, and snippets.

@bad-mushroom
Created March 28, 2014 23:11
Show Gist options
  • Save bad-mushroom/9844887 to your computer and use it in GitHub Desktop.
Save bad-mushroom/9844887 to your computer and use it in GitHub Desktop.
post-receive hook for deploying site based on branch. "master" is pushed to the production site, "development" to the test site.
#!/bin/bash
echo '--- --- --- --- --- --- --- --- --- --- ---'
echo 'Deploying site...'
echo '--- --- --- --- --- --- --- --- --- --- ---'
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
# Master Branch
if [ "master" == "$branch" ]; then
git --work-tree=/path/to/production/site checkout -f $branch
echo 'Changes pushed to production site'
fi
# Development Branch
if [ "development" == "$branch" ]; then
git --work-tree=/path/to/test/site checkout -f $branch
echo 'Changes pushed to test site'
fi
echo '--- --- --- --- --- --- --- --- --- --- ---'
@LucasHild
Copy link

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment