forked from xtoddx/pulley-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink_to_testing
More file actions
23 lines (18 loc) · 746 Bytes
/
link_to_testing
File metadata and controls
23 lines (18 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env ruby
require 'json'
host = ENV.fetch('TEST_URL', 'https://test.com/branch/{{BRANCH}}/')
icon_host = ENV.fetch('TEST_ICON_URL', "#{host}/status_icon")
pulls = JSON.parse(STDIN.read)
pulls.each do |req|
# See lib/integrity/project.rb
integrity_branch = req['branch'].downcase.gsub(/'s/, 's').gsub(/&/, 'and').
.gsub(/[^a-z0-9]+/, '-').gsub(/-*$/, '')
link = host.gsub('{{BRANCH}}', integrity_branch)
icon_link = icon_host.gsub('{{BRANCH}}', integrity_branch)
unless req['body'].include?(link)
req['modified'] = true
req['body'] = "\n" +
"[View Build](#{link})\n\n#{req['body']}"
end
end
puts pulls.to_json