Simplify your Heroku deploy with quick and concise deployment rake tasks.
Add this line to your application's Gemfile:
gem 'paratrooper'
and then execute
bundle
or
install it yourself with
gem install paratrooper
Instantiate Paratrooper with the name of your heroku application.
Paratrooper::Deploy.new('amazing-app')
You can also provide a tag:
Paratrooper::Deploy.new('amazing-app', tag: 'staging')
You can authenticate your Heroku account in a few ways:
- Provide an API Key
Paratrooper::Deploy.new('app', api_key: 'API_KEY')
- Set an environment variable
ENV['HEROKU_API_KEY'] = 'API_KEY'
Paratrooper::Deploy.new('app')
- Local Netrc file
Paratrooper::Deploy.new('app')
This method works via a local Netrc file handled via the Heroku Toolbelt and is the default and preferred method for providing authentication keys.
By providing tag options for Paratrooper, your code can be tagged and deployed from various reference points.
Paratrooper::Deploy.new("staging-app",
tag: 'staging'
)
This will create/update a staging
git tag at HEAD
.
Paratrooper::Deploy.new("amazing-production-app",
tag: 'production',
match_tag_to: 'staging'
)
This will create/update a production
git tag at staging
and deploy the production
tag.
You can use the object's methods any way you'd like, but we've provided a sensible default at Paratrooper#deploy
.
This will perform the following tasks:
- Activate maintenance mode
- Create or update a git tag (if provided)
- Push changes to Heroku
- Run database migrations
- Restart the application
- Deactivate maintenance mode
- Warm application instance
require 'paratrooper'
namespace :deploy do
desc 'Deploy app in staging environment'
task :staging do
deployment = Paratrooper::Deploy.new("amazing-staging-app",
tag: 'staging'
)
deployment.deploy
end
desc 'Deploy app in production environment'
task :production do
deployment = Paratrooper::Deploy.new("amazing-production-app",
tag: 'production',
match_tag_to: 'staging'
)
deployment.deploy
end
end
Our default deploy gets us most of the way, but maybe it's not for you--we've got you covered. Every deployment method sends a notification that can be captured and used in almost any way you can imagine.
For example, say you want to let New Relic know that you are deploying and to disable your application monitoring.
# Gemfile
gem 'paratrooper-newrelic'
# lib/tasks/deploy.rake
require 'paratrooper'
namespace :deploy do
desc 'Deploy app in production environment'
task :production do
deployment = Paratrooper::Deploy.new("amazing-production-app",
tag: 'production',
match_tag_to: 'staging',
notifiers: [
Paratrooper::Notifiers::ScreenNotifier.new,
Paratrooper::Newrelic::Notifier.new('api_key', 'account_id', 'application_id')
]
)
end
end
- The
ScreenNotifier
is added by default so when you override thenotifiers
option you need to manually add it to continue receiving screen output.
To make your own notifier, take a look at Paratrooper::Notifier
to see
what methods are available for override.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
). - Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin my-new-feature
). - Create new Pull Request.
- Rye Mason for the fantastic heading image.