The Comment resource lets you manage GitHub issue and pull request comments. Comments support full GitHub Markdown and can be updated or deleted as needed.
import { Comment } from "alchemy/github";const comment = await Comment("issue-comment", { owner: "my-org", repository: "my-repo", issueNumber: 123, body: "This is a comment created by Alchemy!"});
Comment
The Comment resource lets you manage GitHub issue and pull request comments. Comments support full GitHub Markdown and can be updated or deleted as needed.
Minimal Example
Create a comment on an issue:
Pull Request Comment
Comments work the same way for pull requests:
Update Comment Content
Comments can be updated by changing the body content:
Allow Comment Deletion
By default comments are preserved to maintain discussion history, but you can opt-in to deletion:
Custom Authentication
Pass a custom GitHub token for authentication:
Properties
The Comment resource supports the following properties:
Input Properties
owner
(string, required): Repository owner (user or organization)repository
(string, required): Repository nameissueNumber
(number, required): Issue or Pull Request number to comment onbody
(string, required): Comment body (supports GitHub Markdown)allowDelete
(boolean, optional): Whether to allow deletion of the comment. Default:false
to preserve discussion historytoken
(Secret, optional): GitHub API token. If not provided, uses environment variablesGITHUB_TOKEN
orGITHUB_ACCESS_TOKEN
Output Properties
id
(string): The resource IDcommentId
(number): The numeric ID of the comment in GitHubhtmlUrl
(string): URL to view the commentupdatedAt
(string): Time at which the comment was created/updatedtoken
Authentication
Authentication is handled in the following order:
token
parameter in the resource props (if provided)GITHUB_ACCESS_TOKEN
environment variable (for actions with admin permissions)GITHUB_TOKEN
environment variableThe token must have the following permissions: