@@ -193,18 +193,34 @@ jobs:
193
193
194
194
# Post report as comment to PR:
195
195
- name : ' Post report as comment to PR'
196
- if : github.event_name == 'pull_request '
196
+ if : github.event_name == 'pull_request_target '
197
197
# Pin action to full length commit SHA
198
198
uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
199
199
with :
200
200
github-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
201
201
script : |
202
- github.rest.issues.createComment ({
202
+ const { data: comments } = await github.rest.issues.listComments ({
203
203
issue_number: context.issue.number,
204
204
owner: context.repo.owner,
205
205
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
+ }
208
224
209
225
# Post report as comment to commit:
210
226
- name : ' Post report as comment to commit'
0 commit comments