How to React to a Command Comment in GitHub Actions
A reaction on the command comment tells the author the bot saw the request, without adding another comment to the thread.
Use reactions.createForIssueComment to add a +1 or rocket reaction when a command starts, and a follow-up reaction or comment when it finishes.
Steps
- Grant the job
pull-requests: write(orissues: write). - Call
reactions.createForIssueCommentwith the comment id. - Pick a content value such as
eyes,+1, orrocket.
Reaction step
.github/workflows/ci.yml
permissions:
issues: write
pull-requests: write
jobs:
ack:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
})Gotchas
- Valid reaction contents are limited to
+1,-1,laugh,confused,heart,hooray,rocket,eyes. - slash-command-dispatch can add the initial reaction for you with
reaction-token. - Reactions are cheap feedback; post a comment for detailed results.
Related guides
How to Post Command Results Back to a PR or Slack in GitHub ActionsPost the result of a chat-triggered command back to the pull request or Slack in GitHub Actions, so the reque…
How to Use slash-command-dispatch in GitHub ActionsRoute pull request slash commands to dedicated workflows in GitHub Actions with peter-evans/slash-command-dis…