73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/jenkins/bundle/update/pr.rb', line 73
def self.create_if_needed(git_username: nil, git_email: nil)
raise "$GITHUB_PROJECT_USERNAME isn't set" unless ENV['GITHUB_PROJECT_USERNAME']
raise "$GITHUB_PROJECT_REPONAME isn't set" unless ENV['GITHUB_PROJECT_REPONAME']
raise "$GITHUB_ACCESS_TOKEN isn't set" unless ENV['GITHUB_ACCESS_TOKEN']
return unless need?
now = Time.now
git_username ||= client.user.login
git_email ||= "#{git_username}@users.noreply.github.com"
repo_full_name = "#{ENV['GITHUB_PROJECT_USERNAME']}/#{ENV['GITHUB_PROJECT_REPONAME']}"
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)
(repo_full_name, pull_request[:number])
end
|