public
Created

Heroku Deploy Script

  • Download Gist
deploy.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.