class HerokuDoctor

Public Class Methods

description() click to toggle source
# File lib/abtion_scripts/heroku_doctor.rb, line 4
def self.description
  "Checks the health of your Heroku config"
end
help() click to toggle source
# File lib/abtion_scripts/heroku_doctor.rb, line 8
  def self.help
    <<~TEXT
      abtion heroku-doctor #{colorize(:light_blue, "environment")} = #{colorize(:yellow, "staging")}
    TEXT
  end

Public Instance Methods

run_checks() click to toggle source
# File lib/abtion_scripts/heroku_doctor.rb, line 14
def run_checks
  @env = argv[0] || "staging"
  @heroku_app_name = app_names[@env.to_s]

  puts "Environment: #{@env}"
  puts "Heroku app:  #{@heroku_app_name}"
  puts

  # this one should always be first - it will NEVER pass for the abtion-rails project which is OKAY!
  check(
    name: "The abtion.yml file has been configured properly",
    command: "! grep 'PROJECT-NAME-staging' abtion.yml",
    remedy: "configure your abtion.yml file to have the correct app names set for all your Heroku environments"
  )

  check(
    name: "app #{@heroku_app_name} exists",
    command: "cat .git/config | egrep -e git@heroku.com:#{@heroku_app_name}.git -e https://git.heroku.com/#{@heroku_app_name}.git",
    remedy: [command("heroku apps:create #{@heroku_app_name}"), "and/or", command("git remote add staging git@heroku.com:#{@heroku_app_name}.git")]
  )

  check_remote("production")
  check_remote("staging")

  check_env("DEPLOY_TASKS", "db:migrate")
  check_env("RAILS_ENV", "production")
  check_env("DATABASE_URL", "postgres://", "go to https://dashboard.heroku.com/apps/#{@heroku_app_name}/resources and add the Heroku Postgress add-on")

  check_buildpack("https://github.com/heroku/heroku-buildpack-ruby")
  check_buildpack("https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks")
end

Private Instance Methods

check_buildpack(url) click to toggle source
# File lib/abtion_scripts/heroku_doctor.rb, line 64
def check_buildpack(url)
  check(
    name: url.split("/").last,
    command: "heroku buildpacks -a #{@heroku_app_name} | grep '#{url}'",
    remedy: command("heroku buildpacks:add #{url} -a #{@heroku_app_name}")
  )
end
check_env(env_var, value, remedy=nil) click to toggle source
# File lib/abtion_scripts/heroku_doctor.rb, line 56
def check_env(env_var, value, remedy=nil)
  check(
    name: env_var,
    command: "heroku config:get #{env_var} -a #{@heroku_app_name} | grep '#{value}'",
    remedy: remedy || command("heroku config:set #{env_var}=#{value} -a #{@heroku_app_name}")
  )
end
check_remote(remote) click to toggle source
# File lib/abtion_scripts/heroku_doctor.rb, line 48
def check_remote(remote)
  check(
    name: %|Remote "#{remote}" exists|,
    command: "git remote | grep #{remote}",
    remedy: "heroku git:remote -a #{@heroku_app_name} -r #{remote}"
  )
end