DaanHoogland commented on code in PR #13878:
URL: https://github.com/apache/cloudstack/pull/13878#discussion_r3789199904
##########
.github/workflows/sonar-check.yml:
##########
@@ -106,10 +108,27 @@ 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
// listComments is ordered oldest-first with no direction
option, so take the last match for the most recent comment.
const existing = botComments.reverse().find(c =>
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');
}
```
##########
.github/workflows/sonar-check.yml:
##########
@@ -106,10 +108,27 @@ 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,
});
Review Comment:
```suggestion
const botComments = await github.paginate(
github.rest.issues.listComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
},
response => response.data.filter(c => c.user.login ===
'github-actions[bot]'),
);
```
--
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]