The issue_comment
event occurs for comments on both issues and pull requests. You can use the github.event.issue.pull_request
property in a conditional to take different action depending on whether the triggering object was an issue or pull request.
For example, this workflow will run the pr_commented
job only if the issue_comment
event originated from a pull request. It will run the issue_commented
job only if the issue_comment
event originated from an issue.
on: issue_comment
jobs:
pr_commented:
name: PR comment
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- run: |
echo A comment on PR $NUMBER
env:
NUMBER: ${{ github.event.issue.number }}
issue_commented:
name: Issue comment
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- run: |
echo A comment on issue $NUMBER
env:
NUMBER: ${{ github.event.issue.number }}