DaanHoogland commented on code in PR #13878:
URL: https://github.com/apache/cloudstack/pull/13878#discussion_r3789173995


##########
.github/workflows/sonar-check.yml:
##########
@@ -106,10 +108,26 @@ jobs:
               `> [View full Actions run](${runUrl})`,
             ].filter(l => l !== undefined).join('\n');
 
-            await github.rest.issues.createComment({
+            const { data: comments } = await github.rest.issues.listComments({
               owner:        context.repo.owner,
               repo:         context.repo.repo,
               issue_number: context.issue.number,
-              body:         body,
             });
-            console.log('Posted coverage grade comment');
+           const existing = comments.find(c => c.user.login === 
'github-actions[bot]' && c.body.includes(marker));
+           if (existing) {
+             await github.rest.issues.updateComment({
+               owner:      context.repo.owner,
+               repo:       context.repo.repo,
+               comment_id: existing.id,
+               body:       body,
+             });
+             console.log('Updated existing coverage grade comment');
+           } else {
+             await github.rest.issues.createComment({
+               owner:        context.repo.owner,
+               repo:         context.repo.repo,
+               issue_number: context.issue.number,
+               body:         body,
+             });
+             console.log('Posted coverage grade comment');
+           }

Review Comment:
   ```suggestion
              }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to