From 500a3b5639c934c521e355f94e309ca3a8bc0468 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 14 Aug 2026 15:19:53 +0200 Subject: [PATCH 1/2] Update sonar-check.yml to manage coverage comments Refactor coverage comment handling to update existing comments if present. --- .github/workflows/sonar-check.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sonar-check.yml b/.github/workflows/sonar-check.yml index fbb3cb9f540d..250b601cacb8 100644 --- a/.github/workflows/sonar-check.yml +++ b/.github/workflows/sonar-check.yml @@ -80,12 +80,14 @@ jobs: const emojiMap = { A: '🟢', B: '🟡', C: '🟠', D: '🔴', F: '⛔' }; const emoji = emojiMap[grade] ?? '❓'; const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const marker = ''; const branchRow = branchPct !== 'N/A' ? `| Branch coverage | **${branchPct}%** |` : ''; const body = [ + marker, `## ${emoji} Test Coverage Grade: \`${grade}\` — ${label}`, '', '| Metric | Value |', @@ -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.type === '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'); + } From 43fc5831481a8da89245589f870c2256d18b18f1 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 14 Aug 2026 15:38:40 +0200 Subject: [PATCH 2/2] Apply suggestion --- .github/workflows/sonar-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-check.yml b/.github/workflows/sonar-check.yml index 250b601cacb8..d2d6f55cc5fb 100644 --- a/.github/workflows/sonar-check.yml +++ b/.github/workflows/sonar-check.yml @@ -113,7 +113,7 @@ jobs: repo: context.repo.repo, issue_number: context.issue.number, }); - const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(marker)); + 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,