Skip to content

Instantly share code, notes, and snippets.

@sandrods
Created September 14, 2011 21:15
Show Gist options
  • Save sandrods/1217807 to your computer and use it in GitHub Desktop.
Save sandrods/1217807 to your computer and use it in GitHub Desktop.
git post_receive hook
#!/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