Post summary comment to PR

This commit is contained in:
Shaun Becker 2025-07-23 10:56:55 -04:00
parent b14337a039
commit f88a700220

View file

@ -232,6 +232,33 @@ class TestReporter {
},
...github.context.repo
})
const {pull_request} = github.context.payload
if (pull_request !== undefined && pull_request !== null) {
core.info(`Looking for pre-existing test summary`)
const commentList = await this.octokit.rest.issues.listComments({
...github.context.repo,
issue_number: pull_request.number
})
const targetId = commentList.data.find((el: any) => el.body?.startsWith('# 🚀 TEST RESULT SUMMARY'))?.id
if (targetId !== undefined) {
core.info(`Updating test summary as comment on pull-request`)
await this.octokit.rest.issues.updateComment({
...github.context.repo,
issue_number: pull_request.number,
comment_id: targetId,
body: `# 🚀 TEST RESULT SUMMARY ${summary}`
})
} else {
core.info(`Attaching test summary as comment on pull-request`)
await this.octokit.rest.issues.createComment({
...github.context.repo,
issue_number: pull_request.number,
body: `# 🚀 TEST RESULT SUMMARY ${summary}`
})
}
}
core.info(`Check run create response: ${resp.status}`)
core.info(`Check run URL: ${resp.data.url}`)
core.info(`Check run HTML: ${resp.data.html_url}`)