Skip to content

Commit bdce46c

Browse files
authored
chore: delete the previous ran results before create new comment (#23)
avoid having too many run results in PR comments. e.g. vuejs/core#12935
1 parent a302d8c commit bdce46c

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

.github/workflows/ecosystem-ci-from-pr.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,38 @@ jobs:
233233
}).join("\n")}
234234
`
235235
236-
await github.rest.issues.deleteComment({
237-
owner: context.repo.owner,
238-
repo: 'core',
239-
comment_id: ${{ needs.init.outputs.comment-id }}
240-
})
236+
if (selectedSuite === "-") {
237+
// delete the previous ran results
238+
try {
239+
const { data: comments } = await github.rest.issues.listComments({
240+
issue_number: context.payload.inputs.prNumber,
241+
owner: context.repo.owner,
242+
repo: 'core'
243+
})
244+
const workflowComments = comments.filter(comment =>
245+
comment.body.includes('Ran ecosystem CI:') || comment.body.includes('Triggered ecosystem CI:')
246+
)
247+
for (const comment of workflowComments) {
248+
await github.rest.issues.deleteComment({
249+
owner: context.repo.owner,
250+
repo: 'core',
251+
comment_id: comment.id
252+
});
253+
console.log(`Deleted previous comment: ${comment.id}`);
254+
}
255+
} catch (error) {
256+
console.log('Error when trying to delete previous comments:', error);
257+
}
258+
}
259+
260+
try {
261+
await github.rest.issues.deleteComment({
262+
owner: context.repo.owner,
263+
repo: 'core',
264+
comment_id: ${{ needs.init.outputs.comment-id }}
265+
})
266+
} catch (error) {
267+
}
241268
242269
await github.rest.issues.createComment({
243270
issue_number: context.payload.inputs.prNumber,

0 commit comments

Comments
 (0)