Skip to content

prComment() ​

Post the release comment on the pull request or merge request from code, and know whether it was posted.

Signature ​

ts
function prComment(options?: PrCommentOptions): Promise<boolean>

Options: PrCommentOptions, and ReleaseContext for releaseContext.

Behavior ​

  • Without releaseContext, the comment is the one of relizy pr-comment, read from the package.json files. With a releaseContext, it follows its status (success, no-release, failed); with its report, the comment is the summary of the release, as in release().
  • Resolves true when the comment is posted, or with dryRun when a pull request is found (always with prNumber, even without token), false otherwise: without pull request (the warning tells to set prNumber), without token, or when the API of the provider refuses it (with a warning).
  • Rejects on an error of the config or of the project (e.g. an unreadable root package.json). release() catches it: a failed comment never fails a release.
  • dryRun still calls the API of the provider to find the pull request, and posts nothing.

Example ​

ts
import { loadRelizyConfig, prComment } from 'relizy'

const config = await loadRelizyConfig({ configFile: 'relizy' })

const posted = await prComment({
  config,
  prNumber: Number(process.env.PR_NUMBER),
})

if (!posted) {
  console.warn('No release comment posted')
}

See Also ​