diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 28aeef8..e0c4a0a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -98,12 +98,27 @@ jobs: `; - github.rest.issues.createComment({ + const { data: comments } = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody + repo: context.repo.repo }); + const comment = comments.find(comment => comment.body.includes('## Test Coverage Report')); + if (comment) { + await github.rest.issues.updateComment({ + comment_id: comment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + } else { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + } - name: Post failure comment if: failure() uses: actions/github-script@v6 @@ -126,12 +141,27 @@ jobs: The following checks failed: ${failedStepsDetails} `; - github.rest.issues.createComment({ + const { data: comments } = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody + repo: context.repo.repo }); + const comment = comments.find(comment => comment.body.includes('## Code Quality Checks Failed')); + if (comment) { + await github.rest.issues.updateComment({ + comment_id: comment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + } else { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + } generate-localizations: name: Generate localizations. needs: [code-quality]