(rootDir: string, opts: CommentOptions)
| 304 | * repo's comment onto an arbitrary PR or issue. |
| 305 | */ |
| 306 | export async function ciCommentCommand(rootDir: string, opts: CommentOptions): Promise<void> { |
| 307 | if (!opts.bodyFile) { |
| 308 | log.error('`bumpy ci comment` requires --body-file <path>.'); |
| 309 | process.exit(1); |
| 310 | } |
| 311 | |
| 312 | // Let gh resolve the repo without a checkout (the poster workflow may not check |
| 313 | // anything out). GITHUB_REPOSITORY is set by Actions and is trusted. |
| 314 | if (!process.env.GH_REPO && process.env.GITHUB_REPOSITORY) { |
| 315 | process.env.GH_REPO = process.env.GITHUB_REPOSITORY; |
| 316 | } |
| 317 | |
| 318 | let body: string; |
| 319 | try { |
| 320 | body = readFileSync(resolve(opts.bodyFile), 'utf-8'); |
| 321 | } catch { |
| 322 | // No body file — normal when the PR had no bump-file changes (empty artifact). No-op. |
| 323 | log.dim(` No comment body at ${opts.bodyFile} — nothing to post.`); |
| 324 | return; |
| 325 | } |
| 326 | if (!body.trim()) { |
| 327 | log.dim(' Empty comment body — nothing to post.'); |
| 328 | return; |
| 329 | } |
| 330 | |
| 331 | const prNumber = opts.pr ? validatePrNumber(opts.pr) : resolveTargetPrNumber(rootDir); |
| 332 | if (!prNumber) { |
| 333 | log.error('Could not resolve a target PR. Pass --pr <number> explicitly.'); |
| 334 | process.exit(1); |
| 335 | } |
| 336 | |
| 337 | await postOrUpdatePrComment(prNumber, body, rootDir); |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Resolve which PR to comment on. Under `workflow_run`, derive it from the TRUSTED |
no test coverage detected
searching dependent graphs…