3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/terraspace_ci_github/pr.rb', line 3
def (url)
return unless ENV['GITHUB_EVENT_NAME'] == 'pull_request'
return unless github_token?
repo = ENV['GITHUB_REPOSITORY'] number = ENV['GITHUB_REF_NAME'].split('/').first marker = "<!-- terraspace marker -->"
body = marker + "\n"
body << "Terraspace Cloud Url #{url}"
puts "Adding comment to repo #{repo} number #{number}"
= client.(repo, number)
= .find do ||
.body.starts_with?(marker)
end
if
client.(repo, .id, body) unless .body == body
else
client.(repo, number, body)
end
rescue Octokit::Unauthorized => e
puts "WARN: #{e.message}. Unable to create pull request comment. Please double check your github token"
end
|