Last active
April 21, 2020 21:40
-
-
Save caesar/9425851 to your computer and use it in GitHub Desktop.
Git website deployment post-update script for live and staging with multiple branches. Based on code from http://www.ekynoxe.com/git-post-receive-for-multiple-remote-branches-and-work-trees/
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 | |
live_dir="/path/to/live/site" | |
dev_dir="/path/to/dev/site" | |
while read oldrev newrev ref | |
do | |
branch=`echo $ref | cut -d/ -f3` | |
if [ "master" == "$branch" ]; then | |
git --work-tree=$live_dir checkout -f $branch | |
echo "Changes pushed live." | |
elif [ "develop" == "$branch" ]; then | |
git --work-tree=$dev_dir checkout -f $branch | |
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