Created
September 27, 2011 13:45
-
-
Save wader/1245074 to your computer and use it in GitHub Desktop.
git push post-receive capistrano deploy hook script
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/bash | |
# requires that you use "set :deploy_via, :remote_cache" in deploy.rb | |
while read oldrev newrev ref | |
do | |
if [ "$ref" = "refs/heads/master" ] ; then | |
echo "Master branch pushed, deploying to staging" | |
# seams to be set to "." for hooks, unset to make things more normal | |
unset GIT_DIR | |
# deploy path, where "current", "releases", "shared" etc are | |
DEPLOYDIR="/home/user/deploy/staging" | |
# default path for :deploy_via :remote_cache is shared/cached-copy | |
cd "$DEPLOYDIR/shared/cached-copy" | |
# update cache to pushed revision, will be done by capistrano too | |
git fetch origin && git fetch --tags origin && git reset --hard "$newrev" | |
# load rvm | |
source ~/.rvm/scripts/rvm | |
rvm use 1.9.2 | |
# make sure we have a .bundle directory to make bundle exec happy. | |
# lend the one from current deployed version | |
cp -a "$DEPLOYDIR/current/.bundle" . | |
# run capistrano | |
# if you use deploy:migrations instead of deploy you should probably add | |
# after "deploy:migrations", "deploy:cleanup" | |
# to your deploy.rb | |
bundle exec cap staging deploy:migrations | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment