Heroku ❤️ Rails
Useless tool for easy deploy Ruby on Rails to Heroku
If you're using continuous deployment with pipelines in Heroku, you won't need this. However if that style doesn't work, then this may allow you to manage databases and deployment with more control but less hassle.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install heroku_rails
TODO: Some of these manual configuration steps, would be nicer to make a bit more automatic perhaps by making this a Rails engine. 1) Your database configuration (config/database.yml) needs to have a username if you want to use the db configurations
load "heroku_rails/tasks/db_drop_all_tables.rake" to the end of Rakefile.
3) Copy templates into codebase:
cp $(bundle show heroku_rails)/templates/heroku.thor ./lib/tasks cp $(bundle show heroku_rails)/templates/heroku_targets.yml ./config
4) update heroku_targets.yml with your staging and production targets. My set up for this is to have staging deploy the local version, but production deploy the origin/master.
> TODO: more detail
5) You may want to set up a smoke test that your heroku targets are valid
require "heroku_rails/heroku_targets" RSpec.describe "heroku_targets.yml" do it "is valid (smoke test)" do ::.(Rails.root.join("config/heroku_targets.yml")) end end
Deploy the latest with db migrate during maintenance
thor heroku:deploy staging
or without maintenance
thor heroku:deploy staging --no-maintenance
or without migrating
thor heroku:deploy staging --no-migrate
or a specific tag/branch
thor heroku:deploy staging hotfix-branch
Sync a database down from remote to local
thor heroku:sync:grab -f staging # when it finishes rake db:drop_all_tables && thor heroku:sync:from_dump -f staging
FYI rake db:drop_all_tables is handy as it doesn't require you to disconnect any running processes from the database.
Copy production db to staging
thor heroku:sync:to staging -f production
NB: this won't work from a staging to a production environment (failsafe)
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake spec to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the
.gem file to rubygems.org.
Ensure standards before PR:
bundle exec standardrb --fix
Bug reports and pull requests are welcome on GitHub at https://github.com/siapbantu/heroku_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the HerokuRails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.