Skip to content

Instantly share code, notes, and snippets.

@tylerhunt
Created November 3, 2012 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerhunt/4005288 to your computer and use it in GitHub Desktop.
Save tylerhunt/4005288 to your computer and use it in GitHub Desktop.
Heroku Deploy Script
#!/bin/bash
args=`getopt r:m $*`
if [ $? != 0 ]; then
echo "Usage: $0 [-r heroku] [-m]"
exit 2
fi
set -- $args
for i; do
case "$i"
in
-r)
remote=$2
shift
;;
-m)
migrations=true
shift
;;
--)
shift
break
;;
esac
done
if [ -z "$remote" ]; then
remote="heroku"
fi
if [ -n "$migrations" ] ; then
echo "Deploying to $remote with migrations..."
sleep 2
heroku maintenance:on --remote $remote
git push $remote master
heroku run rake db:migrate --remote $remote
heroku restart --remote $remote
heroku maintenance:off --remote $remote
else
echo "Deploying to $remote..."
sleep 2
git push $remote master
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment