File tree 4 files changed +96
-0
lines changed
4 files changed +96
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ class CML {
163
163
const triggerSha = await this . triggerSha ( ) ;
164
164
const {
165
165
commitSha : inCommitSha = triggerSha ,
166
+ // issue: issueId,
166
167
rmWatermark,
167
168
update,
168
169
pr,
Original file line number Diff line number Diff line change @@ -29,6 +29,33 @@ class BitbucketCloud {
29
29
}
30
30
}
31
31
32
+ async issueCommentCreate ( opts = { } ) {
33
+ const { projectPath } = this ;
34
+ const { issueId, report } = opts ;
35
+ const endpoint = `/repositories/${ projectPath } /issues/${ issueId } /comments/` ;
36
+ return (
37
+ await this . request ( {
38
+ endpoint,
39
+ method : 'POST' ,
40
+ body : JSON . stringify ( { content : { raw : report } } )
41
+ } )
42
+ ) . links . html . href ;
43
+ }
44
+
45
+ async issueCommentUpdate ( opts = { } ) {
46
+ const { projectPath } = this ;
47
+ const { issueId, id, report } = opts ;
48
+
49
+ const endpoint = `/repositories/${ projectPath } /issues/${ issueId } /comments/${ id } ` ;
50
+ return (
51
+ await this . request ( {
52
+ endpoint,
53
+ method : 'PUT' ,
54
+ body : JSON . stringify ( { content : { raw : report } } )
55
+ } )
56
+ ) . links . html . href ;
57
+ }
58
+
32
59
async commentCreate ( opts = { } ) {
33
60
const { projectPath } = this ;
34
61
const { commitSha, report } = opts ;
Original file line number Diff line number Diff line change @@ -540,6 +540,40 @@ class Github {
540
540
}
541
541
}
542
542
543
+ async issueCommentCreate ( opts = { } ) {
544
+ const { issueId, report } = opts ;
545
+ const { owner, repo } = ownerRepo ( { uri : this . repo } ) ;
546
+ const { issues } = octokit ( this . token , this . repo ) ;
547
+
548
+ const {
549
+ data : { html_url : htmlUrl }
550
+ } = await issues . createComment ( {
551
+ owner,
552
+ repo,
553
+ report,
554
+ issue_number : issueId
555
+ } ) ;
556
+
557
+ return htmlUrl ;
558
+ }
559
+
560
+ async issueCommentUpdate ( opts = { } ) {
561
+ const { id, report } = opts ;
562
+ const { owner, repo } = ownerRepo ( { uri : this . repo } ) ;
563
+ const { issues } = octokit ( this . token , this . repo ) ;
564
+
565
+ const {
566
+ data : { html_url : htmlUrl }
567
+ } = await issues . updateComment ( {
568
+ owner,
569
+ repo,
570
+ report,
571
+ comment_id : id
572
+ } ) ;
573
+
574
+ return htmlUrl ;
575
+ }
576
+
543
577
async prCommentCreate ( opts = { } ) {
544
578
const { report : body , prNumber } = opts ;
545
579
const { owner, repo } = ownerRepo ( { uri : this . repo } ) ;
Original file line number Diff line number Diff line change @@ -329,6 +329,40 @@ class Gitlab {
329
329
}
330
330
}
331
331
332
+ async issueCommentCreate ( opts = { } ) {
333
+ const projectPath = await this . projectPath ( ) ;
334
+ const { issueId, report } = opts ;
335
+
336
+ const endpoint = `/projects/${ projectPath } /issues/${ issueId } /notes` ;
337
+ const body = new URLSearchParams ( ) ;
338
+ body . append ( 'body' , report ) ;
339
+
340
+ const { id } = await this . request ( {
341
+ endpoint,
342
+ method : 'POST' ,
343
+ body
344
+ } ) ;
345
+
346
+ return `${ this . repo } /-/issues/${ issueId } #note_${ id } ` ;
347
+ }
348
+
349
+ async issueCommentUpdate ( opts = { } ) {
350
+ const projectPath = await this . projectPath ( ) ;
351
+ const { issueId, id : commentId , report } = opts ;
352
+
353
+ const endpoint = `/projects/${ projectPath } /issues/${ issueId } /notes/${ commentId } ` ;
354
+ const body = new URLSearchParams ( ) ;
355
+ body . append ( 'body' , report ) ;
356
+
357
+ const { id } = await this . request ( {
358
+ endpoint,
359
+ method : 'PUT' ,
360
+ body
361
+ } ) ;
362
+
363
+ return `${ this . repo } /-/issues/${ issueId } #note_${ id } ` ;
364
+ }
365
+
332
366
async prCommentCreate ( opts = { } ) {
333
367
const projectPath = await this . projectPath ( ) ;
334
368
const { report, prNumber } = opts ;
You can’t perform that action at this time.
0 commit comments