Skip to content

Instantly share code, notes, and snippets.

@TheEmpty
Created March 10, 2012 00:22
Show Gist options
  • Select an option

  • Save TheEmpty/2009437 to your computer and use it in GitHub Desktop.

Select an option

Save TheEmpty/2009437 to your computer and use it in GitHub Desktop.
Heroku Deploy
#!/bin/bash
ENV='staging'
BRANCH='master'
GOT=`git status`
EXPECTED="# On branch master
nothing to commit (working directory clean)"
if [ "$GOT" != "$EXPECTED" ]
then
echo 'Please commit your changes to the git repository before deploying to Heroku'
exit
fi
EXEC=`bundle exec rake RAILS_ENV=$ENV RAILS_GROUPS=assets assets:precompile`
GA=`git add .`
GM=`git commit -m 'Automatic heroku deploy'`
git push heroku $BRANCH --force
# TODO: only if a migration was added
echo 'Deployed, now migrating'
heroku rake db:migrate
echo 'Database migrated, removing pre-compiled files'
git reset --hard HEAD^
echo 'All done, application deployed!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment