Created
November 3, 2012 00:47
-
-
Save tylerhunt/4005288 to your computer and use it in GitHub Desktop.
Heroku Deploy 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 | |
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