Verified Environment
Version | |
---|---|
image | ubuntu-20.04 |
What to do
github.event_name == 'issue_comment'
- Issue or Pull Request
- https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment-on-issues-only-or-pull-requests-only
- Issue only:
github.event_name == 'issue_comment' && !github.event.issue.pull_request
- Pull Request only:
github.event_name == 'issue_comment' && github.event.issue.pull_request
- Issue only:
- https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment-on-issues-only-or-pull-requests-only
- Issue or Pull Request
startsWith(github.event.comment.body, '/my-slash-command')
- Check if the comment starts with
/my-slash-command
- Check if the comment starts with
Examples
name: "Slash command"
on:
issue_comment:
types: [created]
jobs:
slash-command:
if: github.event_name == 'issue_comment' &&
startsWith(github.event.comment.body, '/my-slash-command')
runs-on: ubuntu-20.04
env:
REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
COMMENT_ID: ${{ github.event.comment.id }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Add eyes reaction
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$REPO/issues/comments/$COMMENT_ID/reactions \
-f content='eyes'
- uses: actions/checkout@v3
- name: Do something
run: |
# implement something
- name: Add rocket reaction
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$REPO/issues/comments/$COMMENT_ID/reactions \
-f content='rocket'
Add :eyes: and :rocket: reactions are optional.