Class: KapostDeploy::Heroku::AppPromoter

Inherits:
Object
  • Object
show all
Defined in:
lib/kapost_deploy/heroku/app_promoter.rb

Overview

Promotes a heroku app via Heroku Plaform API

Instance Method Summary collapse

Constructor Details

#initialize(pipeline, token:) ⇒ AppPromoter

Returns a new instance of AppPromoter.



9
10
11
12
# File 'lib/kapost_deploy/heroku/app_promoter.rb', line 9

def initialize(pipeline, token:)
  self.pipeline = pipeline
  self.token = token
end

Instance Method Details

#promote(from:, to:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kapost_deploy/heroku/app_promoter.rb', line 14

def promote(from:, to:)
  pipeline_id = discover_pipeline(pipeline)["id"]
  from_id = discover_app(from)["id"]
  to_id   = discover_app(to)["id"]

  promotion_data = {
    pipeline: { id: pipeline_id },
    source: { app: { id: from_id } },
    targets: [{ app: { id: to_id } }]
  }

  wait_for_promotion(heroku.pipeline_promotion.create(promotion_data))
end