This is an action to post a comment to the current pull request. It is inspired from suzuki-shunsuke/github-comment.
This action infers pull request(s) from the context as follows:
- On
pull_requestevent, use the current pull request - On
issueevent, use the current issue - On
pushevent, use pull request(s) associated with the current commit - Otherwise, get pull request(s) associated with
github.sha
You can also specify the issue or pull request number via issue-number input.
To post a comment:
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
post: |
:wave: Hello WorldYou can create an issue or update the issue if exists. It is useful to avoid too many comments in an issue.
To replace the comment if it exists,
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
update-if-exists: replace
post: |
:while_check_mark: The resource has been createdTo append the comment if it exists,
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
update-if-exists: append
post: |
:warning: Creating resourceTo recreate the comment if it exists,
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
update-if-exists: recreate
post: |
:warning: Creating resourceThis action finds the latest comment created by same workflow and job, by default.
It embeds the key into an issue comment as a markdown comment <!-- -->.
If you need to identify a comment to update, set the key as follows:
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
update-if-exists: append
update-if-exists-key: ${{ github.workflow }}/${{ github.job }}/terraform-plan
post: |
:warning: Creating resourceTo run a command and post the output on failure:
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
run: yarn test
post-on-failure: |
## :x: Test failure
```
${run.output}
```You can use the string interpolation in post-on-success and post-on-failure.
The following variables are available:
${run.output}- combined output of the command
${run.code}- exit code of the command
This action does not support any script to keep it simple and secure.
You can still write a script by actions/github-script,
but it would be nice to write your awesome action by a programming language for maintainability.
To post a comment to a specific issue or pull request,
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
issue-number: 12345
post: |
:wave: Hello WorldTo post a comment to a specific issue or pull request in a specific repository,
jobs:
build:
steps:
- uses: int128/comment-action@v1
with:
repository: owner/repo
issue-number: 12345
token: # PAT or GitHub App token is needed for another repository
post: |
:wave: Hello World| Name | Default | Description |
|---|---|---|
post |
- | If set, post a comment to the pull request |
update-if-exists |
(optional) | If set, create or update a comment. This must be either replace, append or recreate |
update-if-exists-key |
${{ github.workflow }}/${{ github.job }} |
Key for update-if-exists |
run |
- | If set, run a command |
post-on-success |
(optional) | If set, post a comment on success of the command |
post-on-failure |
(optional) | If set, post a comment on failure of the command |
repository |
${{ github.repository }} |
Repository name in the format of owner/repo |
issue-number |
(optional) | Number of an issue or pull request on which to create a comment |
token |
github.token |
GitHub token |
Either post or run must be set.
