A GitHub Action to add a comment to all open Pull Requests in a repository.
This action adds a custom comment to all open Pull Requests (PRs) in a repository. It is useful, for example, to notify developers about updates or important events directly in PRs.
To use this action in your repository, add the following to your .github/workflows/<your-workflow>.yml
file:
name: Add PR Comment
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
add-pr-comment:
runs-on: ubuntu-latest
steps:
- name: Add comment to PR
uses: paulo9mv/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
message: "Hey everyone, code review is always welcome!"
token (required): The GitHub token to authenticate the action. Use ${{ secrets.GITHUB_TOKEN }} to allow the action to interact with the repository. message (required): The message that will be posted on the PRs.
The GITHUB_TOKEN has limited permissions by default, and you may need to configure them to ensure the action can add comments to PRs.
If you are using the action in your repository and the action cannot add comments, add the following to your workflow.yml file, inside the job that uses the action:
permissions:
issues: write # Permission to add and modify comments on issues and PRs
pull-requests: write # Permission to add comments on pull requests
These permissions will ensure that the action has access to interact with PRs.
Here’s a complete example of a workflow that adds a comment to all PRs when there’s a new update:
name: Add Comment to PRs
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
add-pr-comment:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Add comment to PR
uses: paulo9mv/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
message: "Hey everyone, code review is always welcome!"
If you have suggestions or improvements for this action, feel free to open a Pull Request or Issue.
Distributed under the MIT License. See the LICENSE file for more details.