Comment
Source:
src/GitHub/Comment.ts
A GitHub issue or pull request comment.
Comment manages the lifecycle of a single comment on an issue or pull
request. Comments are created on the first deploy and updated in place on
subsequent deploys when the body changes. By default, comments are never
deleted to preserve discussion history — set allowDelete: true to opt in.
Authentication is resolved in order: explicit token prop,
GITHUB_ACCESS_TOKEN env var, GITHUB_TOKEN env var. The token needs
repo scope for private repositories or public_repo for public ones.
Creating Comments
Section titled “Creating Comments”Comment on an Issue
const comment = yield* GitHub.Comment("issue-comment", { owner: "my-org", repository: "my-repo", issueNumber: 123, body: "This is a comment created by Alchemy!",});Comment on a Pull Request
const prComment = yield* GitHub.Comment("pr-comment", { owner: "my-org", repository: "my-repo", issueNumber: 456, body: "## Deployment Status\n\nSuccessfully deployed to staging!",});Updating Comments
Section titled “Updating Comments”Deploy with the same logical ID and a different body to update the
existing comment in place rather than creating a new one.
const comment = yield* GitHub.Comment("status-comment", { owner: "my-org", repository: "my-repo", issueNumber: 789, body: "Deployment completed successfully!",});Deleting Comments
Section titled “Deleting Comments”const comment = yield* GitHub.Comment("temp-comment", { owner: "my-org", repository: "my-repo", issueNumber: 123, body: "This comment can be deleted", allowDelete: true,});CI Preview Comments
Section titled “CI Preview Comments”A common pattern is posting a preview-deployment URL on every pull request. The comment auto-updates on each push because the logical ID stays the same.
if (process.env.PULL_REQUEST) { yield* GitHub.Comment("preview-comment", { owner: "my-org", repository: "my-repo", issueNumber: Number(process.env.PULL_REQUEST), body: Output.interpolate` ## Preview Deployed
**URL:** ${website.url} `, });}