Class: Deploy::Runner
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, #pull_image, #push_image, #run_deploy, #run_rollback, #tag_image_as_latest
Methods included from Output
#announce, #colorize, #green, #notifier, #pink, #red, #shout, #yellow
Instance Method Details
#deploy ⇒ Object
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
39
40
|
# 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']
if build && !version_exists?(version)
announce_title = "Deployment started with build"
build_image(repo, version)
else
announce_title = "Deployment started without build"
pull_image(repo, version)
end
tag_image_as_latest(repo, version)
push_image(repo, version)
push_image(repo, 'latest')
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
|
#rollback ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/deploy/runner.rb', line 45
def rollback
check_setup
environment = options[:environment]
version = options[:version]
check_rollback_version(version, environment)
repo = ENV['DOCKER_REPO']
announce({ color: '#6080C0', title: "Rollback started", text: "Rolling back to #{version} on #{environment}" })
pull_image(repo, version)
tag_image_as_latest(repo, version)
push_image(repo, 'latest')
run_rollback(version, environment)
announce({ color: 'good', title: 'Rollback Succeeded!!', text: "The current version of #{environment} is #{version}" })
end
|
#setup ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/deploy/runner.rb', line 89
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_slack ⇒ Object
67
68
69
|
# File 'lib/deploy/runner.rb', line 67
def test_slack
notifier('', { color: 'good', title: 'This is a test notification from eb-docker-deploy.' })
end
|
#version ⇒ Object
82
83
84
85
86
|
# File 'lib/deploy/runner.rb', line 82
def version
check_setup
shout current_version_for_environment(options[:environment])
end
|
#versions ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/deploy/runner.rb', line 72
def versions
check_setup
application_versions_array.each do |version|
shout version
end
end
|