Created
September 14, 2011 21:15
-
-
Save sandrods/1217807 to your computer and use it in GitHub Desktop.
git post_receive hook
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/sh | |
exit_with_error() { | |
echo "!!!! An error has occurred !!!!" | |
exit 1 | |
} | |
# Initial directory is .git, so go to the working copy directory | |
cd .. | |
export RAILS_ENV="production" | |
echo "************************" | |
echo "Deploying application..." | |
echo "************************" | |
# Add everything to the index and then reset hard to both sweep changed files (like cached pages) | |
# and update the working copy. | |
echo "------> Updating application working tree" | |
env -i git add . | |
env -i git reset --hard || exit_with_error | |
echo "------> Restarting app" | |
mkdir -p log | |
mkdir -p tmp | |
if [ -e lib/deploy_hooks/post-receive ]; then | |
lib/deploy_hooks/post-receive | |
fi | |
touch tmp/restart.txt | |
echo "------> Successfully deployed app" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment