/hanzo

:hocho: Hanzo is a sharp tool to handle deploying an application on Heroku on multiple environments.

Primary LanguageRubyBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Hanzo
Hanzo is a sharp tool to handle deploying an application on Heroku on multiple environments.


Installation

Add this line to your application’s Gemfile:

gem 'hanzo'

Usage

Create a .hanzo.yml file at the root of your app that will contain a map of remotes, with the remote as the key and the Heroku application name as the value.

You can also use after_deploy to specify commands that will be run on the application after a successful deployment. Hanzo will prompt you before running each command, then use heroku run to execute it. The application is restarted afterwards.

remotes:
  qa: heroku-app-name-qa
  staging: heroku-app-name-staging
  production: heroku-app-name-production

after_deploy:
  - rake db:migrate

console: rails console

hanzo install

Remotes

Whenever you add new remotes to your .hanzo.yml file, you'll have to install them locally by running hanzo install remotes.

$ hanzo install remotes
-----> Creating git remotes
       Adding qa
        git remote rm qa 2>&1 > /dev/null
        git remote add qa https://git.heroku.com/heroku-app-name-qa.git
       Adding staging
        git remote rm staging 2>&1 > /dev/null
        git remote add staging https://git.heroku.com/heroku-app-name-staging.git
       Adding production
        git remote rm production 2>&1 > /dev/null
        git remote add production https://git.heroku.com/heroku-app-name-production.git

Labs

Once all your remotes are installed, you might want to enable Heroku labs features:

$ hanzo install labs
-----> Activating Heroku Labs
       Add preboot? yes
       - Enabled for qa
       - Enabled for staging
       - Enabled for production
       Add user-env-compile? yes
       - Enabled for qa
       - Enabled for staging
       - Enabled for production

hanzo deploy

You can deploy to a specific remote using hanzo deploy <remote> and an optional reference to deploy. If no reference is specified, Hanzo will prompt for one (with HEAD as the default value).

$ hanzo deploy qa release/qa
       git push -f qa release/qa:master

       …

remote: Verifying deploy... done.
To heroku.com:heroku-app-name-qa.git
   550c719..27e3538  release/qa -> master

       Run `rake db:migrate` on qa? y
       heroku run rake db:migrate --remote qa

Running rake db:migrate on heroku-app-name-qa...
15:45:26.380 [info] Already up
       heroku ps:restart --remote qa

Restarting dynos on heroku-app-name-qa...

hanzo diff

You can use hanzo diff <remote> to compare the current repository state to the code that is currently deployed in the specified remote.

Warning: This uses Heroku’s git repository references so its output might be wrong if the application was rollbacked.

$ hanzo diff qa
       git remote update qa && git diff qa/master...HEAD
────────────────────────────────────────────────────────────────────────────────────────────
 -- a/lib/my_app/router.ex
 ++ b/lib/my_app/router.ex
────────────────────────────────────────────────────────────────────────────────────────────
@@ -30,6 +30,8 @@ defmodule MyApp.Router do
    plug(:fetch_flash)
+   plug(:protect_from_forgery)
+   plug(:put_secure_browser_headers)

hanzo config

Compare

You can use hanzo config compare to find out which environment variables are present in only some of your environments.

$ hanzo config compare
-----> Fetching environment variables
       heroku config -r qa
       heroku config -r staging
       heroku config -r production

-----> Comparing environment variables
       Missing variables in qa
       - ASSET_HOST
       Missing variables in staging
       - SMTP_PASSWORD
       - SMTP_PORT
       - SMTP_SERVER
       - SMTP_USER
       Missing variables in production
       - SMTP_PASSWORD
       - SMTP_PORT
       - SMTP_SERVER
       - SMTP_USER

hanzo console

You can define a console command in .hanzo.yml to quickly spawn a console process using heroku run.

$ hanzo console qa
Running iex -S mix on heroku-app-name-qa... up
> |

License

Hanzo is © 2013-2018 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.