Module: Circleci::Bundle::Update::Pr

Defined in:
lib/circleci/bundle/update/pr.rb,
lib/circleci/bundle/update/pr/version.rb

Constant Summary collapse

VERSION =
"1.2.1"

Class Method Summary collapse

Class Method Details

.create_if_needed(git_username: nil, git_email: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/circleci/bundle/update/pr.rb', line 9

def self.create_if_needed(git_username: nil, git_email: nil)
  raise "$CIRCLE_PROJECT_USERNAME isn't set" unless ENV['CIRCLE_PROJECT_USERNAME']
  raise "$CIRCLE_PROJECT_REPONAME isn't set" unless ENV['CIRCLE_PROJECT_REPONAME']
  raise "$GITHUB_ACCESS_TOKEN isn't set" unless ENV['GITHUB_ACCESS_TOKEN']
  return unless need?
  repo_full_name = "#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
  now = Time.now
  branch = "bundle-update-#{now.strftime('%Y%m%d%H%M%S')}"
  create_branch(git_username, git_email, branch)
  pull_request = create_pull_request(repo_full_name, branch, now)
  add_comment_of_compare_linker(repo_full_name, pull_request[:number])
end