Class: Jumpup::Deis::Integrate

Inherits:
Object
  • Object
show all
Defined in:
lib/jumpup/deis/integrate.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Integrate

Returns a new instance of Integrate.



46
47
48
49
# File 'lib/jumpup/deis/integrate.rb', line 46

def initialize(app)
  @app = app
  @envs = Env.all
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/jumpup/deis/integrate.rb', line 8

def app
  @app
end

Class Method Details

.add_remoteObject



26
27
28
29
30
31
# File 'lib/jumpup/deis/integrate.rb', line 26

def self.add_remote
  message = "Adding Deis git remotes for app #{integrate.app}"
  integrate.when_branch_send_to_deis(message) do
    integrate.add_remote
  end
end

.checkObject



33
34
35
36
37
38
# File 'lib/jumpup/deis/integrate.rb', line 33

def self.check
  message = "Checking if there's already someone integrating to #{integrate.app}"
  integrate.when_branch_send_to_deis(message) do
    integrate.check
  end
end

.deployObject



10
11
12
13
14
15
# File 'lib/jumpup/deis/integrate.rb', line 10

def self.deploy
  message = "Starting to deploy on Deis app #{integrate.app}"
  integrate.when_branch_send_to_deis(message) do
    integrate.deploy
  end
end

.deploy_to_productionObject



17
18
19
20
21
22
23
24
# File 'lib/jumpup/deis/integrate.rb', line 17

def self.deploy_to_production
  app = Env.all[:production_app]
  integrate = new(app)
  message = "Starting to deploy to production on Deis app #{integrate.app}"
  integrate.when_branch_send_to_deis(message) do
    integrate.deploy_to_production
  end
end

.integrateObject



40
41
42
43
44
# File 'lib/jumpup/deis/integrate.rb', line 40

def self.integrate
  envs = Env.all
  app = envs[:app] || envs[:staging_app]
  new(app)
end

Instance Method Details

#add_remoteObject



83
84
85
86
# File 'lib/jumpup/deis/integrate.rb', line 83

def add_remote
  remote = run_with_clean_env("git remote | grep deis").strip
  exec_with_clean_env("git remote add deis ssh://git@#{host}:2222/#{app}.git") if remote.blank?
end

#branches_that_send_to_deisObject



60
61
62
# File 'lib/jumpup/deis/integrate.rb', line 60

def branches_that_send_to_deis
  [Env.all[:deploy_branch], Env.all[:deploy_to_production_branch]]
end

#deployObject



64
65
66
67
68
69
70
# File 'lib/jumpup/deis/integrate.rb', line 64

def deploy
  run_database_checks if run_database_tasks?

  push(Env.all[:deploy_branch])
  migrate if run_database_tasks?
  seed if run_database_tasks?
end

#deploy_to_productionObject



72
73
74
75
76
77
78
79
80
81
# File 'lib/jumpup/deis/integrate.rb', line 72

def deploy_to_production
  run_database_checks if run_database_tasks?

  confirm_deploy
  spec
  tag
  push(Env.all[:deploy_to_production_branch])
  migrate if run_database_tasks?
  seed if run_database_tasks?
end

#when_branch_send_to_deis(message, &block) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/jumpup/deis/integrate.rb', line 51

def when_branch_send_to_deis(message, &block)
  puts "--> #{message}"
  if branches_that_send_to_deis.include?(actual_branch)
    block.call
  else
    puts "----> Skipping since you are in a feature branch [#{actual_branch}]"
  end
end