push from your git repo to a heroku app without any external configuration
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
integration
lib
spec
.gitignore
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
heroku-headless.gemspec

README.md

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} git@heroku.com:#{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

Enable force push:

require 'heroku-headless'

 app_name = 'my-heroku-app-name'

 HerokuHeadless.configure do | config |
   config.force_push = 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