Sha256: b37aa2a2b54e56d20a0036d0649983fcad4850e93ec72a6bdc97aab4d5af79e1
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require "platform-api" module KapostDeploy module Heroku # Promotes a heroku app via Heroku Plaform API class AppPromoter def initialize(pipeline, token:) self.pipeline = pipeline self.token = token end 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 private attr_accessor :pipeline attr_accessor :token def wait_for_promotion(promotion) while promotion["status"] == "pending" print "." sleep 1 promotion = heroku.pipeline_promotion.info(promotion["id"]) end end def discover_pipeline(pipeline) heroku.pipeline.info(pipeline) end def discover_app(app_name) heroku.app.info(app_name) end def heroku @heroku ||= PlatformAPI.connect(token) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kapost_deploy-0.2.0 | lib/kapost_deploy/heroku/app_promoter.rb |