@@ -21,10 +21,11 @@ export async function handleKBIssue(
2121
2222 if ( resp . status == 200 ) {
2323 let old_body = resp . data . body ;
24- let action_name = get_action ( issue . title ) ;
24+ let action_name = getAction ( issue . title ) ;
2525 if ( old_body . indexOf ( action_name ) >= 0 ) {
2626 core . info ( `[!] Action ${ action_name } is already being tracked` ) ;
27- return "Issue already being tracked" ;
27+ let ret = await closeIssue ( octokit , owner , repo , issue )
28+ return ret ;
2829 }
2930
3031 let new_body = old_body + comment ;
@@ -38,19 +39,8 @@ export async function handleKBIssue(
3839 core . info ( `[X] Unable to add: ${ issue . number } in the tracking comment` ) ;
3940 } else {
4041 core . info ( `[!] Added ${ issue . title } in tracking comment.` ) ;
41- let resp3 = await octokit . rest . issues . update ( {
42- owner : owner ,
43- repo : repo ,
44- issue_number : issue . number ,
45- state : "closed" ,
46- } ) ;
47- if ( resp3 . status === 200 ) {
48- core . info ( `[!] Closed Issue ${ issue . number } ` ) ;
49- return "success" ;
50- } else {
51- core . info ( `[X] Unable to close issue ${ issue . number } ` ) ;
52- return "error: unable to close issue" ;
53- }
42+ let ret = await closeIssue ( octokit , owner , repo , issue )
43+ return ret ;
5444 }
5545 }
5646 core . info ( `[X] Unable to handle: ${ issue . title } ` ) ;
@@ -100,7 +90,23 @@ async function prepareComment(
10090 } ) ;
10191}
10292
103- function get_action ( x ) {
93+ function getAction ( x ) {
10494 x = x . split ( " " ) ;
10595 return x [ 6 ] ;
106- }
96+ }
97+
98+ async function closeIssue ( octokit , owner , repo , issue ) {
99+ let resp3 = await octokit . rest . issues . update ( {
100+ owner : owner ,
101+ repo : repo ,
102+ issue_number : issue . number ,
103+ state : "closed" ,
104+ } ) ;
105+ if ( resp3 . status === 200 ) {
106+ core . info ( `[!] Closed Issue ${ issue . number } ` ) ;
107+ return "success" ;
108+ } else {
109+ core . info ( `[X] Unable to close issue ${ issue . number } ` ) ;
110+ return "error: unable to close issue" ;
111+ }
112+ }
0 commit comments