Sha256: 052306117101861b0a9509be71256f0e5e404fee92e5bb47e8c16c7ea97f0a51

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

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 = "Usage: hanzo deploy ENVIRONMENT"
    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?')
        Hanzo.run "heroku run rake db:migrate --remote #{@env}" if migration
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanzo-0.2.1 lib/hanzo/modules/deploy.rb
hanzo-0.2 lib/hanzo/modules/deploy.rb