@@ -193,18 +193,34 @@ jobs:
193193
194194 # Post report as comment to PR:
195195 - name : ' Post report as comment to PR'
196- if : github.event_name == 'pull_request '
196+ if : github.event_name == 'pull_request_target '
197197 # Pin action to full length commit SHA
198198 uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
199199 with :
200200 github-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
201201 script : |
202- github.rest.issues.createComment ({
202+ const { data: comments } = await github.rest.issues.listComments ({
203203 issue_number: context.issue.number,
204204 owner: context.repo.owner,
205205 repo: context.repo.repo,
206- body: '${{ steps.create-report.outputs.report }}'
207- })
206+ });
207+
208+ const isBotComment = comments.find(comment => comment.user.login === 'stdlib-bot' && comment.body.includes('## Coverage Report'));
209+ if (isBotComment) {
210+ await github.rest.issues.updateComment({
211+ owner: context.repo.owner,
212+ repo: context.repo.repo,
213+ comment_id: botComment.id,
214+ body: `${{ steps.create-report.outputs.report }}`,
215+ });
216+ } else {
217+ await github.rest.issues.createComment({
218+ issue_number: context.issue.number,
219+ owner: context.repo.owner,
220+ repo: context.repo.repo,
221+ body: `${{ steps.create-report.outputs.report }}`,
222+ });
223+ }
208224
209225 # Post report as comment to commit:
210226 - name : ' Post report as comment to commit'
0 commit comments