Sha256: 21e93566383ae579a65ad0b51e82d615d43b2b2c6b1d6a4f8269d5a5cd3b2776

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

module Hanzo
  class Deploy < Base

  protected

    def initialize_variables
      @env = extract_argument(1)

      if @env.nil? and Hanzo::Installers::Remotes.environments.keys.length == 1
        @env = Hanzo::Installers::Remotes.environments.keys.first
      end
    end

    def initialize_cli
      initialize_help and return if @env.nil?

      deploy
      run_migrations
    end

    def initialize_help
      @options.banner = <<-BANNER.unindent
        Usage: hanzo deploy ENVIRONMENT

        Available environments
      BANNER

      Hanzo::Installers::Remotes.environments.each do |env|
        @options.banner << "  - #{env.first}\n"
      end
    end

    def deploy
      branch = Hanzo.ask("Branch to deploy in #{@env}:") { |q| q.default = "HEAD" }

      Hanzo.run "git push -f #{@env} #{branch}:master"
    end

    def run_migrations
      if Dir.exists?('db/migrate')
        migration = Hanzo.agree('Run migrations?')

        if migration
          Hanzo.run "heroku run rake db:migrate --remote #{@env}"
          Hanzo.run "heroku ps:restart --remote #{@env}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanzo-0.4.2 lib/hanzo/modules/deploy.rb
hanzo-0.4.1 lib/hanzo/modules/deploy.rb
hanzo-0.4 lib/hanzo/modules/deploy.rb
hanzo-0.3.1 lib/hanzo/modules/deploy.rb