Class: Deploy::Runner

Inherits:
Thor
  • Object
show all
Includes:
Checks, Commands, Output, Utility, Versions
Defined in:
lib/deploy/runner.rb

Instance Method Summary collapse

Methods included from Utility

#command?

Methods included from Versions

#application_versions_array, #current_version_for_environment, #eb, #version_exists?

Methods included from Checks

#check_rollback_version, #check_setup, #check_version

Methods included from Commands

#build_image, #create_deploy_zip_file, #pull_image, #push_image, #run_deploy, #run_rollback, #use_tag_in_dockerrun

Methods included from Output

#announce, #colorize, #green, #notifier, #pink, #red, #shout, #yellow

Instance Method Details

#deployObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/deploy/runner.rb', line 13

def deploy
  check_setup

  environment = options[:environment]
  build = options[:build]

  version = options[:version]
  check_version(version, environment)

  repo = ENV['DOCKER_REPO']

  use_tag_in_dockerrun(repo, version)
  create_deploy_zip_file

  if build && !version_exists?(version)
    announce_title = "Deployment started with an image that was just built"
    build_image(repo, version)
    push_image(repo, version)
  else
    announce_title = "Deployment started with an image that was already built"
  end

  announce({ color: '#6080C0', title: announce_title, text: "Deploying version #{version} to #{environment}" })
  run_deploy(version, environment)
  announce({ color: 'good', title: 'Deployment Succeeded!!', text: "The current version of #{environment} is #{version}" })
end

#setupObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/deploy/runner.rb', line 63

def setup
  (shout('AWS creds already configured in ~/.bashrc'); exit(1)) if ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY'] && ENV['AWS_REGION']

  key = ask('Enter AWS Key:')
  secret = ask('Enter AWS Secret:')
  region = ask('Enter AWS Region:', default: 'us-west-2')

  File.open(File.expand_path('~/.bashrc'), 'a') do |f|
    f.puts ''
    f.puts '# Variables defined by eb-docker-deploy:'
    f.puts "export AWS_ACCESS_KEY_ID=#{key}"
    f.puts "export AWS_SECRET_ACCESS_KEY=#{secret}"
    f.puts "export AWS_REGION=#{region}"
  end

  shout('AWS creds successfully configured at ~/.bashrc.')
  shout('You must now run "source ~/.bashrc"')
end

#test_slackObject



41
42
43
# File 'lib/deploy/runner.rb', line 41

def test_slack
  notifier('', { color: 'good', title: 'This is a test notification from eb-docker-deploy.' })
end

#versionObject



56
57
58
59
60
# File 'lib/deploy/runner.rb', line 56

def version
  check_setup

  shout current_version_for_environment(options[:environment])
end

#versionsObject



46
47
48
49
50
51
52
# File 'lib/deploy/runner.rb', line 46

def versions
  check_setup

  application_versions_array.each do |version|
    shout version
  end
end