Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 15244a4

Browse files
committed
post a comment when input[params][comment] exists
1 parent 32193f7 commit 15244a4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

assets/lib/out.rb

+8
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,12 @@
3737
context: context
3838
).create!
3939

40+
if input['params']['comment']
41+
comment_path = File.join(destination, input['params']['comment'])
42+
raise %(`path` "#{input['params']['comment']}" does not exist) unless File.exist?(comment_path)
43+
44+
comment = File.read(comment_path, encoding: Encoding::UTF_8)
45+
Octokit.add_comment(input['source']['repo'], id, comment)
46+
end
47+
4048
json!(version: version, metadata: metadata)

spec/integration/out_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ def request_body(method, url)
7070
])
7171
end
7272

73+
it 'set into success mode with posting a comment' do
74+
File.open(File.join(dest_dir, 'comment'), 'w+') do |f|
75+
f.write('message')
76+
end
77+
proxy.stub("https://api.github.com:443/repos/jtarchie/test/statuses/#{@sha}", method: :post)
78+
proxy.stub("https://api.github.com:443/repos/jtarchie/test/issues/1/comments", method: :post)
79+
.and_return(json: { id: 1 })
80+
81+
output, error = put(params: { status: 'success', path: 'resource', comment: 'resource/comment' }, source: { repo: 'jtarchie/test' })
82+
expect(output).to eq('version' => { 'ref' => @sha, 'pr' => '1' },
83+
'metadata' => [
84+
{ 'name' => 'status', 'value' => 'success' },
85+
{ 'name' => 'url', 'value' => 'http://example.com' }
86+
])
87+
end
88+
89+
7390
context 'with bad params' do
7491
it 'raises an error when path is missing' do
7592
_, error = put(params: { status: 'pending' }, source: { repo: 'jtarchie/test' })

0 commit comments

Comments
 (0)