Skip to content

Instantly share code, notes, and snippets.

@tonicospinelli
Last active December 28, 2015 06:39
Show Gist options
  • Select an option

  • Save tonicospinelli/7459150 to your computer and use it in GitHub Desktop.

Select an option

Save tonicospinelli/7459150 to your computer and use it in GitHub Desktop.
Git Hook Post Receive - simple deploy for main branches into differents pathsThanks #ekynoxe for your explanationshttp://blog.ekynoxe.com/2011/10/22/automated-deployment-on-remote-server-with-git/
#!/bin/bash
livepath="/path/www/master.dev"
devpath="/var/www/develop.dev"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=$livepath checkout -f $branch
echo $livepath
echo 'Changes pushed live.'
elif [ "develop" == "$branch" ]; then
git --work-tree=$devpath checkout -f $branch
echo $devpath
echo 'Changes pushed to dev.'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment