Class: HerokuRailsDeploy::Deployer
- Inherits:
-
Object
- Object
- HerokuRailsDeploy::Deployer
- Extended by:
- PrivateAttr
- Defined in:
- lib/heroku_rails_deploy/deployer.rb
Defined Under Namespace
Classes: Options
Constant Summary collapse
- PRODUCTION_BRANCH_REGEX =
/\A((master)|(release\/.+)|(hotfix\/.+))\z/- PRODUCTION =
'production'.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
Instance Method Summary collapse
-
#initialize(config_file, args) ⇒ Deployer
constructor
A new instance of Deployer.
- #production? ⇒ Boolean
- #run ⇒ Object
Constructor Details
#initialize(config_file, args) ⇒ Deployer
Returns a new instance of Deployer.
25 26 27 28 29 30 31 |
# File 'lib/heroku_rails_deploy/deployer.rb', line 25 def initialize(config_file, args) raise "Missing config file #{config_file}" unless File.file?(config_file) @app_registry = YAML.load(File.read(config_file)) @config_file = config_file @args = args @options = end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
16 17 18 |
# File 'lib/heroku_rails_deploy/deployer.rb', line 16 def args @args end |
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
16 17 18 |
# File 'lib/heroku_rails_deploy/deployer.rb', line 16 def config_file @config_file end |
Instance Method Details
#production? ⇒ Boolean
72 73 74 |
# File 'lib/heroku_rails_deploy/deployer.rb', line 72 def production? .try(:environment) == PRODUCTION end |
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/heroku_rails_deploy/deployer.rb', line 33 def run return unless app_name = app_registry.fetch(.environment) do raise OptionParser::InvalidArgument.new("Invalid environment '#{.environment}'. " \ "Must be in #{app_registry.keys.join(', ')}") end raise 'Only master, release or hotfix branches can be deployed to production' if production? && !production_branch?(.revision) no_uncommitted_changes! puts "Deploying to Heroku app #{app_name} for environment #{.environment}" if !.skip_avro_schemas && (production? || .register_avro_schemas) puts 'Checking for pending Avro schemas' pending_schemas = list_pending_schemas(app_name) if pending_schemas.any? puts 'Registering Avro schemas' register_avro_schemas!(registry_url(app_name), pending_schemas) else puts 'No pending Avro schemas' end end puts 'Pushing code' push_code(app_name, .revision) puts 'Checking for pending migrations' if pending_migrations?(app_name) puts 'Running migrations' run_migrations(app_name) puts 'Restarting dynos' restart_dynos(app_name) else puts 'No migrations required' end end |