Class: Brut::CLI::Apps::Deploy::Heroku

Inherits:
Commands::BaseCommand show all
Defined in:
lib/brut/cli/apps/deploy.rb

Instance Attribute Summary

Attributes inherited from Commands::BaseCommand

#parent_command

Instance Method Summary collapse

Methods inherited from Commands::BaseCommand

#accepts, #args_description, #argv, #bootstrap?, #commands, #delegate_to_command, #detailed_description, #env, #env_vars, #execute, #name, #options, #puts, #stdin, #system!, #theme

Instance Method Details

#default_rack_envObject



19
# File 'lib/brut/cli/apps/deploy.rb', line 19

def default_rack_env = "development"

#descriptionObject



13
# File 'lib/brut/cli/apps/deploy.rb', line 13

def description = "Deploy to Heroku using container-based deployment"

#optsObject



14
15
16
17
# File 'lib/brut/cli/apps/deploy.rb', line 14

def opts = [
  [ "--[no-]deploy", "If true, actually deploy the pushed images (default true)" ],
  [ "--skip-checks", "If true, skip pre-build checks" ],
]

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/brut/cli/apps/deploy.rb', line 21

def run
  options.set_default(:deploy, true)
  puts "Logging in to Heroku Container Registry"
  command = %{heroku container:login}
  system!(command)
  execute_result = Brut::CLI::ExecuteResult.new do
    delegate_to_command(
      Brut::CLI::Apps::Deploy::Build.new(
        push: options.deploy? ? "registry.heroku.com/#{Brut.container.app_id}/%{name}": false
      )
    )
  end
  if execute_result.failed?
    puts theme.error.render("Build failed.")
    return execute_result.exit_status do |error_message|
      puts theme.error.render("Error message from build: #{error_message}")
    end
  end
  names = []
  app_docker_files = AppDockerImages.new(
    project_root: Brut.container.project_root,
    organization: Brut.container.app_organization,
    app_id: Brut.container.app_id,
    short_version: "NA"
  )
  app_docker_files.each do |name:, cmd:, dockerfile:|
    names << name
  end

  deploy_command = "heroku container:release #{names.join(' ')} -a #{Brut.container.app_id}"
  if options.deploy?
    puts "Deploying images to Heroku"
    system!(deploy_command)
  else
    puts "Not deploying.  To deploy the images just pushed:"
    puts ""
    puts "  #{deploy_command}"
  end
end