>> Workflow to add a comment when an issue or a pull request is opened <<
Drop this snippet in a separate file in your .github/workflows
directory:
name: CI
on:
issues:
types:
- opened
jobs:
add-issue-comment:
uses: rednafi/i-have-seen/.github/workflows/seen.yml@v2
with:
# Markdown syntax is allowed.
message: |
Simple comment **works**.
This is another ~line~.
where: "issues"
Whenever an issue is created, action-bot will add a comment like this:
Similar to the previous section, drop this snippet in .github/workflows
directory to
add a comment after a pull request is opened:
name: CI
on:
pull_request:
types:
- opened
jobs:
add-pr-comment:
uses: rednafi/i-have-seen/.github/workflows/seen.yml@v2
# Markdown syntax is allowed.
with:
message: |
Simple comment **works**.
This is another ~line~.
where: "pull_request"
Upon the creation of a pull request, a comment will appear as follows:
This snippet will make sure that comments are added to both newly opened issues or pull requests:
name: CI
on:
issues:
types:
- opened
pull_request:
types:
- opened
jobs:
add-issue-comment:
uses: rednafi/i-have-seen/.github/workflows/seen.yml@v2
with:
message: |
Simple comment **works**.
This is another ~line~.
where: "issues"
add-pr-comment:
uses: rednafi/i-have-seen/.github/workflows/seen.yml@v2
with:
message: |
Simple comment **works**.
This is another ~line~.
where: "pull_request"
The following CI snippet will ensure that a comment will be added to an issue or a pull
request only when it's labeled with bug
:
name: Test
on:
issues:
types:
- labeled
pull_request:
types:
- labeled
jobs:
add-issue-comment:
if: ${{ github.event.label.name == "bug" }}
uses: rednafi/i-have-seen/.github/workflows/seen.yml@v2
with:
message: |
Simple comment **works**.
This is another ~line~.
where: "issues"
add-pr-comment:
if: ${{ github.event.label.name == "bug" }}
uses: rednafi/i-have-seen/.github/workflows/seen.yml@v2
with:
message: |
Simple comment **works**.
This is another ~line~.
where: "pull_request"
Now, if you create an issue or a pull request and label that with bug
, this action-bot
will add a comment there. This can be seen in action here.