Files
growstuff/script/heroku_maintenance.rb
Daniel O'Connor 81060cccf7 Ruby 3.2: Rubocop - Lint/* and Style/* (#3786)
* Rubocop - Layout/*
* Rubocop - Lint and Style
2024-07-13 15:38:37 +09:30

27 lines
657 B
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'platform-api'
require 'yaml'
heroku = PlatformAPI.connect(ENV.fetch('HEROKU_API_KEY', nil))
branch = ENV.fetch('TRAVIS_BRANCH', nil)
travis_config = YAML.load_file('.travis.yml')
if travis_config['deploy']['app'].key? branch
app = travis_config['deploy']['app'][branch]
else
abort "No Heroku app found for branch #{branch}"
end
case ARGV[0]
when "on"
maintenance_state = true
when "off"
maintenance_state = false
else
abort "usage: #{$PROGRAM_NAME} (on|off)"
end
puts "Turning #{maintenance_state} maintenance mode on app #{app}"
heroku.app.update app, maintenance: maintenance_state