A GitHub action that comments with a given message the pull request linked to the pushed branch. You can even put dynamic data thanks to Contexts and expression syntax.
on: pull_request
jobs:
example_comment_pr:
runs-on: ubuntu-latest
name: An example job to comment a PR
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Comment PR
uses: thollander/actions-comment-pull-request@v1
with:
message: 'Example of message !'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
See examples in opened PR !
ℹ️ : Add if: ${{ github.event_name == 'pull_request' }}
to this Action's step if your workflow is not only triggered by a pull_request
event. It will ensure that you don't throw an error on this step.
You can explicitly input which pull request should be commented on by passing the pr_number
input.
That is particularly useful for manual workflow for instance (workflow_run
).
...
- name: Comment PR
uses: thollander/actions-comment-pull-request@v1
with:
message: 'Example of message !'
pr_number: 123 # This will comment on pull request #123
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The build steps transpiles the src/main.ts
to lib/main.js
which is used in the Docker container.
It is handled by Typescript compiler.
$ npm run build
If you prefer not to download a full action, this can now be easily done thanks to github scripts.
- name: 'Comment PR'
uses: actions/[email protected]
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
github.issues.createComment({ issue_number, owner, repo, body: 'Hello world ! 👋' });