Skip to main content

gh-issue-add-comment

info

This promotion step is only available in Kargo on the Akuity Platform, versions v1.11.0 and above.

The gh-issue-add-comment step posts a comment on an existing GitHub issue or pull request. The returned commentID can be passed to gh-issue-update-comment or gh-issue-delete-comment in later steps.

note

In GitHub, pull requests share the same number space as issues. Passing a PR number as issueNumber posts a comment on the PR's conversation thread. The url in the step output automatically points to the PR (/pull/) rather than the issue (/issues/), because GitHub's API returns the correct URL based on whether the number belongs to a PR or an issue.

GitHub Issues integration for Kargo is a group of promotion steps:

  1. gh-issue-add-comment
  2. gh-create-issue
  3. gh-issue-delete-comment
  4. gh-search-issues
  5. gh-issue-update-comment
  6. gh-update-issue
  7. gh-wait-for-issue-state

Credentials

These steps use the same repository credentials that git-clone and git-open-pr use for the same repository. If you have already configured a Git credential for the repoURL, no additional setup is required.

The GitHub token must have Issues: Read and write access for the repository (or the repo scope for a classic personal access token).

Configuration

NameTypeRequiredDescription
repoURLstringYThe URL of the GitHub repository (e.g. https://github.com/owner/repo).
insecureSkipTLSVerifybooleanNIf true, TLS verification of the GitHub server certificate is skipped. Use only for GitHub Enterprise Server instances with self-signed certificates.
issueNumberintegerYThe number of the issue or pull request to comment on. Pull requests and issues share the same number space in GitHub, so this field works for both.
bodystringYThe body text of the comment. Supports GitHub Flavored Markdown.

Output

NameTypeDescription
commentIDintegerThe ID of the created comment.
urlstringThe HTML URL of the created comment.

Examples

Comment on an issue

Posts a comment when a promotion starts and removes it if the promotion fails:

steps:
- as: post-comment
uses: gh-issue-add-comment
config:
repoURL: https://github.com/myorg/myrepo
issueNumber: ${{ freightMetadata(ctx.targetFreight.name)['github-issue-number'] }}
body: |
Promotion to **${{ ctx.stage }}** started.
Image: `${{ imageFrom(vars.imageRepo).RepoURL }}:${{ imageFrom(vars.imageRepo).Tag }}`

# ... your promotion steps ...

- uses: gh-issue-delete-comment
if: ${{ failure() && status('post-comment') == 'Succeeded' }}
config:
repoURL: https://github.com/myorg/myrepo
commentID: ${{ outputs['post-comment'].commentID }}

Comment on a pull request

Posts a promotion status comment directly on the PR that triggered the promotion. The PR number is stored in freight metadata by an upstream step:

steps:
- uses: gh-issue-add-comment
config:
repoURL: https://github.com/myorg/myrepo
issueNumber: ${{ freightMetadata(ctx.targetFreight.name)['github-pr-number'] }}
body: |
Promoted to **${{ ctx.stage }}** successfully.