@@ -14,16 +14,33 @@ export const comment = async (
1414 const commentBody = `
1515## PR Checks Complete\n
1616${ analyzeStr ?. output } \n
17- ${ codeFormattingStr ?. output } \n
18- ${ testingStr ?. output } \n `;
17+ ${ codeFormattingStr ?. output }
18+ ${ testingStr ?. output } `;
1919 // ## Coverage = ${coverageStr?.output}\n`
2020
21- await ocotokit . rest . issues . createComment ( {
21+ const { data : comments } = await ocotokit . rest . issues . listComments ( {
2222 issue_number : context . issue . number ,
2323 owner : context . repo . owner ,
2424 repo : context . repo . repo ,
25- body : commentBody ,
2625 } ) ;
26+ const comment = comments . find ( ( comment ) =>
27+ comment . body ! . includes ( "PR Checks Complete" ) ,
28+ ) ;
29+ if ( comment ) {
30+ await ocotokit . rest . issues . updateComment ( {
31+ comment_id : comment . id ,
32+ owner : context . repo . owner ,
33+ repo : context . repo . repo ,
34+ body : commentBody ,
35+ } ) ;
36+ } else {
37+ await ocotokit . rest . issues . createComment ( {
38+ issue_number : context . issue . number ,
39+ owner : context . repo . owner ,
40+ repo : context . repo . repo ,
41+ body : commentBody ,
42+ } ) ;
43+ }
2744 return { output : "Comment successful" , error : false } ;
2845 } catch ( error ) {
2946 if ( error instanceof Error ) setFailed ( error . message ) ;
0 commit comments