Class: Deploy::Deployer

Inherits:
Thor
  • Object
show all
Includes:
Output
Defined in:
lib/deploy/deployer.rb

Instance Method Summary collapse

Methods included from Output

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

Instance Method Details

#deployObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/deploy/deployer.rb', line 25

def deploy
  check_setup

  build = options[:build]

  version = options[:version]
  (shout('You must pass a version with -v'); exit(1)) unless version

  repo = ENV['DOCKER_REPO']
  
  if build
    build_image(repo, version)

    tag_image_as_latest(repo, version)

    push_image(repo, version)
    push_image(repo, 'latest')
  end

  run_deploy(version)
end

#rollbackObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/deploy/deployer.rb', line 49

def rollback
  version = options[:version]
  (shout('You must pass a version with -v'); exit(1)) unless version

  repo = ENV['DOCKER_REPO']

  tag_image_as_latest(repo, version)

  push_image(repo, 'latest')

  run_deploy(version)
end

#setupObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/deploy/deployer.rb', line 6

def setup
  (shout('AWS creds already configured at ~/.aws/config.'); exit(1)) if File.exist?(File.expand_path('~/.aws/config'))

  key = ask('Enter AWS Key:')
  secret = ask('Enter AWS Secret:')

  Dir.mkdir(File.expand_path('~/.aws'))

  File.open(File.expand_path('~/.aws/config'), 'w') do |f|
    f.puts '[default]'
    f.puts "aws_access_key_id = #{key}"
    f.puts "aws_secret_access_key = #{secret}"
  end
  (shout('AWS creds successfully configured at ~/.aws/config.'); exit(0)) if File.exist?(File.expand_path('~/.aws/config'))
end