Created
September 28, 2011 18:11
-
-
Save rfreebern/1248724 to your computer and use it in GitHub Desktop.
git post-receive hook for atomic 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
On server: | |
mkdir -p ~/deploy/mysite.git && cd $_ | |
git init --bare | |
(place the post-receive file in hooks/post-receive) | |
mkdir -p /var/www/mysite | |
Make sure your virtual host's DocumentRoot is set to /var/www/mysite/live | |
On development machine: | |
git remote add deploy ssh://username@server/home/username/deploy/mysite.git | |
git push deploy master |
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
#!/bin/sh | |
PRODUCTION_DIR=/var/www/mysite | |
LATEST_REV=`git rev-parse HEAD` | |
DEPLOY_TIMESTAMP=`date +%Y-%m-%d-%H-%M-%S` | |
mkdir $PRODUCTION_DIR/$DEPLOY_TIMESTAMP-$LATEST_REV | |
GIT_WORK_TREE=$PRODUCTION_DIR/$DEPLOY_TIMESTAMP-$LATEST_REV git checkout -f | |
ln -sf $PRODUCTION_DIR/$DEPLOY_TIMESTAMP-$LATEST_REV $PRODUCTION_DIR/live |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment