| 218 | } |
| 219 | |
| 220 | async function updateComment(github: Github, context: Context, body: string) { |
| 221 | const { data: comments } = await github.issues.listComments({ |
| 222 | issue_number: context.issue.number, |
| 223 | owner: context.repo.owner, |
| 224 | repo: context.repo.repo, |
| 225 | }) |
| 226 | |
| 227 | const existing_comment = comments.find( |
| 228 | item => item.user!.login === "github-actions[bot]", |
| 229 | ) |
| 230 | |
| 231 | if (existing_comment) { |
| 232 | return await github.issues.updateComment({ |
| 233 | comment_id: existing_comment.id, |
| 234 | issue_number: context.issue.number, |
| 235 | owner: context.repo.owner, |
| 236 | repo: context.repo.repo, |
| 237 | body, |
| 238 | }) |
| 239 | } |
| 240 | else { |
| 241 | return await github.issues.createComment({ |
| 242 | issue_number: context.issue.number, |
| 243 | owner: context.repo.owner, |
| 244 | repo: context.repo.repo, |
| 245 | body, |
| 246 | }) |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | function getFileName(text: string) { |
| 251 | /* eslint-disable prefer-regex-literals */ |