File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ // @ts -check
2
+ /// <reference lib="esnext.asynciterable" />
3
+ // Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
4
+ const Octokit = require ( "@octokit/rest" ) ;
5
+ const fs = require ( "fs" ) ;
6
+
7
+ const requester = process . env . requesting_user ;
8
+ const source = process . env . source_issue ;
9
+ const postedComment = process . env . status_comment ;
10
+ console . log ( `Loading fragment from ${ process . argv [ 3 ] } ...` ) ;
11
+ const outputTableText = fs . readFileSync ( process . argv [ 3 ] , { encoding : "utf8" } ) ;
12
+ console . log ( `Fragment contents:
13
+ ${ outputTableText } `) ;
14
+
15
+ const gh = new Octokit ( ) ;
16
+ gh . authenticate ( {
17
+ type : "token" ,
18
+ token : process . argv [ 2 ]
19
+ } ) ;
20
+ gh . issues . createComment ( {
21
+ number : + source ,
22
+ owner : "Microsoft" ,
23
+ repo : "TypeScript" ,
24
+ body : `@${ requester }
25
+ The results of the perf run you requested are in! Here they are:
26
+
27
+ ${ outputTableText } `
28
+ } ) . then ( async data => {
29
+ console . log ( `Results posted!` ) ;
30
+ const newCommentUrl = data . data . html_url ;
31
+ const comment = await gh . issues . getComment ( {
32
+ owner : "Microsoft" ,
33
+ repo : "TypeScript" ,
34
+ comment_id : + postedComment
35
+ } ) ;
36
+ const newBody = `${ comment . data . body }
37
+
38
+ Update: [The results are in!](${ newCommentUrl } )` ;
39
+ return await gh . issues . updateComment ( {
40
+ owner : "Microsoft" ,
41
+ repo : "TypeScript" ,
42
+ comment_id : + postedComment ,
43
+ body : newBody
44
+ } ) ;
45
+ } ) . catch ( e => {
46
+ console . error ( e ) ;
47
+ process . exit ( 1 ) ;
48
+ } ) ;
You can’t perform that action at this time.
0 commit comments