Skip to content

Instantly share code, notes, and snippets.

@andrepadez
Created November 21, 2014 09:33
Show Gist options
  • Save andrepadez/3fbffe59cccf7901f1b2 to your computer and use it in GitHub Desktop.
Save andrepadez/3fbffe59cccf7901f1b2 to your computer and use it in GitHub Desktop.
git post-receive hook for deployment by branch
#!/bin/bash
echo "Running Post-Receive hook"
while read oldrev newrev ref ; do
if [ "$ref" == "refs/heads/master" ]; then
GIT_WORK_TREE=/home/josh/production/sonimcampaign git checkout -f
echo 'branch master deployed to live'
elif [ "$ref" == "refs/heads/staging" ]; then
git symbolic-ref HEAD refs/heads/staging
GIT_WORK_TREE=/home/josh/staging/sonimcampaign git checkout -f
git symbolic-ref HEAD refs/heads/master
echo "branch staging deployed to staging"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment