rednafi / i-have-seen

Automatically add a single comment every time an ISSUE or a PULL REQUEST is created

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

i-have-seen

>> Workflow to add a comment when an issue or a pull request is opened <<

actions-badge

Usage

Add an issue comment

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:

issue-comment

Add a pull request comment

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:

pr-comment

Add both issue & pull request comments

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"

Add comments only when an issue or a pull request contains a specific label

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.

🍰

About

Automatically add a single comment every time an ISSUE or a PULL REQUEST is created

License:MIT License