Class: Envirobly::Deployment
Instance Method Summary collapse
-
#initialize(environment, options) ⇒ Deployment
constructor
A new instance of Deployment.
Constructor Details
#initialize(environment, options) ⇒ Deployment
Returns a new instance of Deployment.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/envirobly/deployment.rb', line 2 def initialize(environment, ) commit = Envirobly::Git::Commit.new .commit unless commit.exists? $stderr.puts "Commit #{.commit} doesn't exist in this repository. Aborting." exit 1 end config = Envirobly::Config.new(commit) config.validate if config.errors.any? $stderr.puts "Errors found while parsing #{Envirobly::Config::PATH}:" $stderr.puts config.errors.each do |error| $stderr.puts " - #{error}" end $stderr.puts $stderr.puts "Please fix these, commit the changes and try again." exit 1 end config.compile(environment) params = config.to_deployment_params puts "Deployment config:" puts params.to_yaml exit if .dry_run? api = Envirobly::Api.new response = api.create_deployment params deployment_url = response.object.fetch("url") response = api.get_deployment_with_delay_and_retry deployment_url credentials = Envirobly::Aws::Credentials.new response.object.fetch("credentials") bucket = response.object.fetch("bucket") puts "Uploading build context, please wait..." unless commit.archive_and_upload(bucket:, credentials:).success? $stderr.puts "Error exporting build context. Aborting." exit 1 end puts "Build context uploaded." api.put_as_json deployment_url # TODO: Output URL to watch the deployment progress end |