Module: Executive::Production

Defined in:
lib/executive.rb

Class Method Summary collapse

Class Method Details

.deployObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/executive.rb', line 112

def self.deploy
  remote = "heroku"

  puts              ">> Deploying Production".green

  if `git log origin/master..HEAD` != ""
    puts                ">> Pushing to Github".green
    ensure_system_call  %Q(git push origin master)
  end

  migrations_present = (`git log heroku/master..HEAD -- db/migrate/` != "")

  if migrations_present
    puts                ">> Turning On Maintenance Mode".green
    ensure_system_call  "heroku maintenance:on"
  end

  puts                ">> Deploying to Heroku".green
  ensure_system_call  "git push #{remote} master"

  if migrations_present
    ensure_system_call  "heroku run rake db:migrate"
  end

  if migrations_present
    puts                ">> Turning Off Maintenance Mode".green
    ensure_system_call  "heroku maintenance:off"
  end
end

.ensure_system_call(command) ⇒ Object



105
106
107
108
109
110
# File 'lib/executive.rb', line 105

def self.ensure_system_call(command)
  unless system(command)
    puts %Q(>> Error Running: "#{command}").red
    exit
  end
end