Skip to content

feat(github): add comment_key input for sticky PR/issue comments#1

Closed
0xLLLLH wants to merge 9 commits into
devfrom
feat/comment-key
Closed

feat(github): add comment_key input for sticky PR/issue comments#1
0xLLLLH wants to merge 9 commits into
devfrom
feat/comment-key

Conversation

@0xLLLLH
Copy link
Copy Markdown
Owner

@0xLLLLH 0xLLLLH commented Jun 2, 2026

Summary

Adds a new optional comment_key input to the GitHub Action. When set, OpenCode upserts a single comment per issue/PR thread instead of posting a new comment on every run.

Behaviour

Scenario Result
comment_key unset / blank Create a new comment every run (no change to existing behaviour)
comment_key set Find the most recent bot comment with matching anchor → update it; create new if not found
Multiple matches Update most recent, log warning

Anchor format

The key is sha256-hashed and embedded as an invisible HTML comment in the body:

<!-- opencode:comment-key:sha256:<digest> -->

This safely handles arbitrary characters in the key without escaping rules.

Usage

- uses: opencode-ai/opencode/github@latest
  with:
    comment_key: review-summary   # or ${{ github.workflow }}-${{ github.job }}

Changes

  • github/action.yml: add comment_key input, wire as COMMENT_KEY env var
  • packages/opencode/src/cli/cmd/github.ts: export buildCommentKeyDigest / appendCommentAnchor; add publishComment() upsert entrypoint; replace all createComment() call sites
  • packages/opencode/test/cli/github-action.test.ts: unit tests for the two new pure functions
  • packages/web/src/content/docs/github.mdx: Sticky comments section + updated PR example

0xLLLLH added 3 commits June 3, 2026 00:55
Add a new optional  input to the GitHub Action. When set,
OpenCode upserts a single comment per issue/PR thread instead of creating
a new comment on every run.

- github/action.yml: add  input, wire as COMMENT_KEY env var
- github.ts: export buildCommentKeyDigest and appendCommentAnchor pure
  helpers; add commentKeyDigest(), findExistingStickyComment() and
  publishComment() inside the run handler; replace all createComment()
  call sites with publishComment()
- test: add unit tests for buildCommentKeyDigest and appendCommentAnchor
- docs: add Sticky comments section with usage table and key explanation;
  update PR Example to include comment_key

Behaviour:
- COMMENT_KEY unset/blank  → create a new comment every run (no change)
- COMMENT_KEY set          → search current issue/PR for a bot comment
                             whose body contains
                             <!-- opencode:comment-key:sha256:<digest> -->
                             and update it; create if not found
- Multiple matches         → update the most recent one, log a warning
@0xLLLLH 0xLLLLH force-pushed the feat/comment-key branch from 6169478 to 89e2201 Compare June 2, 2026 16:55
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
6 tasks
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot closed this Jun 2, 2026
@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant