Build Status Dependency Status Code Climate

HerokuHeadless

What?

Push from your git repo to a heroku app without any external configuration.

Why?

Heroku's workflow is geared towards pushing to a heroku app from a dev workstation. This gem makes it easy to push to a heroku app as part of a CI/CD setup.

Installation

Add this line to your application's Gemfile:

gem 'heroku-headless'

And then execute:

$ bundle

Or install it yourself as:

$ gem install heroku-headless

How do I use this?

It's as simple as

require 'heroku-headless'
HerokuHeadless::Deployer.deploy( 'your-app-name' )

Use it with pre- and post-commands:

require 'heroku-headless'

  app_name = 'my-heroku-app-name'
  remote_name = 'herokuheadless'

  puts "deploying to heroku app #{app_name}"
  remote_name = "headlessheroku"
  HerokuHeadless.configure do | config |
    config.post_deploy_commands = ['rake db:migrate']
    config.pre_deploy_git_commands = [
      "git remote -v",
      "git checkout master",
      "git commit -am  \"changes from headless deploy\" ",
      "git remote add #{remote_name} [email protected]:#{app_name}.git",
      "git fetch #{remote_name}",
      "git merge -m \"merged by automatic deploy\" #{remote_name}/master"]
  end

  result = HerokuHeadless::Deployer.deploy( app_name )
  puts "successfully deployed to #{app_name}" if result
  exit result ? 0 : 1

Restart processes after deployment and post-commands:

require 'heroku-headless'

  app_name = 'my-heroku-app-name'
  remote_name = 'herokuheadless'

  puts "deploying to heroku app #{app_name}"
  remote_name = "headlessheroku"
  HerokuHeadless.configure do | config |
    config.post_deploy_commands = ['rake db:migrate']
    config.restart_processes = true
  end

  result = HerokuHeadless::Deployer.deploy( app_name )
  puts "successfully deployed to #{app_name}" if result
  exit result ? 0 : 1

Tell me more!

Deploying To Heroku From CI

Deploying to Heroku From CI - the Gory Details