Class: Envirobly::Deployment
- Inherits:
-
Object
- Object
- Envirobly::Deployment
- Defined in:
- lib/envirobly/deployment.rb
Constant Summary collapse
- URL_MATCHER =
/^https:\/\/envirobly\.(test|com)\/(\d+)\/environs\/(\d+)$/
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.
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 50 51 52 53 54 |
# File 'lib/envirobly/deployment.rb', line 4 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) if config.parsing_error? $stderr.puts "Error while parsing #{config.path}" $stderr.puts config.parsing_error exit 1 end params = { environ: { logical_id: environment }, commit: { ref: @commit.ref, time: @commit.time, message: @commit. }, config: config.to_h } puts params.to_json unless environment =~ URL_MATCHER if project_url = config.dig("remote", "origin") params[:environ][:project_url] = project_url else $stderr.puts "{remote.origin} is required in .envirobly/project.yml" exit 1 end end api = Envirobly::Api.new response = api.create_deployment params response = api.get_deployment_with_delay_and_retry response.object.fetch("url") @credentials = Envirobly::Aws::Credentials.new response.object.fetch("credentials") @bucket = response.object.fetch("bucket") if archive_commit_and_upload $stderr.puts "Build context exported into #{archive_uri}" else $stderr.puts "Error exporting build context. Aborting." exit 1 end end |