Sha256: 93f3cee318402ec12ff3252e5c6fbfb1262f04b2dcd52a531c6404df49a77d2f
Contents?: true
Size: 1.62 KB
Versions: 4
Compression:
Stored size: 1.62 KB
Contents
class Fourchette::Fork include Fourchette::Logger def initialize params @params = params @heroku = Fourchette::Heroku.new @github = Fourchette::GitHub.new end def update create_unless_exists options = { source_blob: { url: "https://github.com/#{ENV['FOURCHETTE_GITHUB_PROJECT']}/archive/#{branch_name}.tar.gz?token=#{ENV['FOURCHETTE_GITHUB_PERSONAL_TOKEN']}" } } build = @heroku.client.build.create(fork_name, options) monitor_build(build) end def monitor_build build build_info = @heroku.client.build.info(fork_name, build['id']) while build_info['status'] == 'pending' build_info = @heroku.client.build.info(fork_name, build['id']) sleep 5 end fail Fourchette::DeployException if build_info['status'] == 'failed' end def create @github.comment_pr(pr_number, "Fourchette is initializing a new fork.") if Fourchette::DEBUG create_unless_exists update end def delete @heroku.delete(fork_name) # Update PR with URL @github.comment_pr(pr_number, "Test app deleted!") end def fork_name "#{ENV['FOURCHETTE_HEROKU_APP_PREFIX']}-PR-#{pr_number}".downcase # It needs to be lowercase only. end def branch_name @params['pull_request']['head']['ref'] end def pr_number @params['pull_request']['number'] end private def create_unless_exists unless @heroku.app_exists?(fork_name) @heroku.fork(ENV['FOURCHETTE_HEROKU_APP_TO_FORK'] ,fork_name) # Update PR with URL @github.comment_pr(pr_number, "Test URL: #{@heroku.client.app.info(fork_name)['web_url']}") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fourchette-0.0.6 | lib/fourchette/fork.rb |
fourchette-0.0.5 | lib/fourchette/fork.rb |
fourchette-0.0.4 | lib/fourchette/fork.rb |
fourchette-0.0.3 | lib/fourchette/fork.rb |