Created
August 31, 2010 11:59
-
-
Save vcastellm/558927 to your computer and use it in GitHub Desktop.
Git auto update hook for web deployment
This file contains hidden or 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
echo "Enter an existing repository name:" | |
read REPONAME | |
cd /home/git/repositories/$REPONAME.git | |
echo "Configuring bare git repo..." | |
git --bare update-server-info | |
git config core.bare false | |
git config receive.denycurrentbranch ignore | |
git config core.worktree /var/www/$REPONAME | |
mkdir /var/www/$REPONAME | |
chown git:git /var/www/$REPONAME | |
echo "Working out the hook" | |
cat >> hooks/post-receive <<-"EOA" | |
#!/bin/sh | |
read oldrev newrev ref | |
BRANCH=`echo $ref | cut -d / -f 3-` | |
if [ "$BRANCH" = "staging" ]; then | |
echo "Deploying $BRANCH..." | |
git checkout staging -f | |
chmod -R u+rwX,go+rX `git config core.worktree` | |
fi | |
EOA | |
chmod +x hooks/post-receive | |
echo "==================================================" | |
echo "Instructions " | |
echo "==================================================" | |
echo "Your repository has been configured to deploy to: " | |
echo "/var/wwww/$REPONAME" | |
echo "To deploy push to a remote branch named staging" | |
echo "==================================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bash <(curl -s https://raw.github.com/gist/558927/git_deploy.sh)