@@ -12,10 +12,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
1212const core = require ( "@actions/core" ) ;
1313const github = require ( "@actions/github" ) ;
1414const rest_1 = require ( "@octokit/rest" ) ;
15+ const REACTION_LIST = [
16+ "+1" ,
17+ "-1" ,
18+ "laugh" ,
19+ "hooray" ,
20+ "confused" ,
21+ "heart" ,
22+ "rocket" ,
23+ "eyes"
24+ ] ;
1525function run ( ) {
26+ var _a ;
1627 return __awaiter ( this , void 0 , void 0 , function * ( ) {
1728 try {
1829 const message = core . getInput ( 'message' ) ;
30+ const reactions = core . getInput ( 'reactions' ) ;
1931 const github_token = core . getInput ( 'GITHUB_TOKEN' ) ;
2032 const context = github . context ;
2133 if ( context . payload . pull_request == null ) {
@@ -28,10 +40,40 @@ function run() {
2840 } ) ;
2941 const new_comment = yield octokit . issues . createComment ( Object . assign ( Object . assign ( { } , context . repo ) , { issue_number : pull_request_number , body : message } ) ) ;
3042 ;
43+ if ( reactions ) {
44+ const repo = ( _a = process . env . GITHUB_REPOSITORY ) === null || _a === void 0 ? void 0 : _a . split ( '/' ) ;
45+ yield addReactions ( octokit , repo , new_comment . data . id , reactions ) ;
46+ }
3147 }
3248 catch ( error ) {
3349 core . setFailed ( error . message ) ;
3450 }
3551 } ) ;
3652}
53+ function addReactions ( octokit , repo , commentId , reactions ) {
54+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
55+ let ReactionsSet = [
56+ ...new Set ( reactions
57+ . replace ( / \s / g, "" )
58+ . split ( "|" )
59+ . filter ( ( reaction ) => {
60+ if ( ! REACTION_LIST . includes ( reaction ) ) {
61+ return false ;
62+ }
63+ return true ;
64+ } ) ) ,
65+ ] ;
66+ if ( ! ReactionsSet ) {
67+ return false ;
68+ }
69+ let results = yield Promise . all ( ReactionsSet . map ( ( reaction ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
70+ yield octokit . reactions . createForIssueComment ( {
71+ owner : repo [ 0 ] ,
72+ repo : repo [ 1 ] ,
73+ comment_id : commentId ,
74+ content : reaction ,
75+ } ) ;
76+ } ) ) ) ;
77+ } ) ;
78+ }
3779run ( ) ;
0 commit comments