GitHub Action
Sticky Pull Request Comment
Create a comment on a pull request, if it exists update that comment. This library runs with GitHub Actions. If you feel that the example grammar below is not friendly enough, we recommend reading this page first.
You need to add permissions for this tool.
permissions:
pull-requests: write
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>
In some cases, different actions may require different comments. The header allows you to maintain comments independently.
release:
...
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: release
message: |
Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>
test:
...
- name: Run Test
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "test_result<<$EOF" >> "$GITHUB_ENV"
rake test >> "$GITHUB_ENV"
echo "$EOF" >> "$GITHUB_ENV"
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: test
message: |
```
${{ env.test_result }}
```
test:
...
- name: Run Test
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "test_result<<$EOF" >> "$GITHUB_ENV"
rake test >> "$GITHUB_ENV"
echo "$EOF" >> "$GITHUB_ENV"
- uses: marocchino/sticky-pull-request-comment@v2
with:
append: true
message: |
Test with ${{ github.sha }}.
```
${{ env.test_result }}
```
If for some reason, triggering on pr is not possible, you can use push.
- uses: jwalton/gh-find-current-pr@v1
id: finder
- uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ steps.finder.outputs.pr }}
message: |
Test ${{ github.sha }} ended successfully.
This message is from a push.
uses: marocchino/sticky-pull-request-comment@v2
with:
path: path-to-comment-contents.txt
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
message: |
Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>
uses: marocchino/sticky-pull-request-comment@v2
with:
header: <same-header-as-the-step-that-added-the-comment>
delete: true
uses: marocchino/sticky-pull-request-comment@v2
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
message: |
Release ${{ github.sha }} to <https://pr-${{ github.event.number }}.example.com>
uses: marocchino/sticky-pull-request-comment@v2
with:
header: <same-header-as-the-step-that-added-the-comment>
hide: true
hide_classify: "OUTDATED"
This tool requires write permission, and that message means the requester does not have enough permission. Recently, GitHub sets permissions conservatively for newly created repositories. If it's a newly created repository, check your Settings > Actions > General > Workflow permissions, and make sure to enable read and write permissions.
Then, you can specify permissions for the job like this:
permissions:
pull-requests: write
For more detailed information about permissions, you can read from the link below: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
Optional Header to determine if the comment should be updated (it is not shown to users). It can be used when you want to add multiple comments independently to a given object.
Optional Indicate if new comment messages should be appended to previous comment message. Only true
is allowed. Just skip this option when you don't need it.
Optional Indicate if previous comment should be removed before creating a new comment. Only true
is allowed. Just skip this option when you don't need it.
Optional Delete a previously created comment. Use header
to point to which comment you want to delete. Only true
is allowed (i.e. delete this option if you don't need it).
Optional Only create a new comment if there is no existing one, otherwise do nothing. Only true
is allowed. Just skip this item when you don't need it. This options has higher priority than hide_and_recreate, hide.
Optional Only update a exist comment if there is existing one, otherwise do nothing. Only true
is allowed. Just skip this item when you don't need it.
Optional Hide a previously created comment. Use header
to point to which comment you want to delete. Only true
is allowed (i.e. delete this option if you don't need it).
Optional The reasons a piece of content can be reported or minimized. SPAM, ABUSE, OFF_TOPIC, OUTDATED, DUPLICATE, RESOLVED are available. default is OUTDATED.
Optional Hide summary tags in the previously created comment. Only true
is allowed. Just skip this item when you don't need it.
Optional Indicate if previous comment should be removed before creating a new comment. Only true
is allowed. Just skip this option when you don't need it.
Optional Comment message
Optional Path to file containing comment message
Optional Pull request number for push event. Note that this has a lower priority than the number of a pull_request event.
Optional Another repository owner, If not set, the current repository owner is used by default. Note that when you trying changing a repo, be aware that GITHUB_TOKEN
should also have permission for that repository.
Optional Another repository name. Of limited use on GitHub enterprise. If not set, the current repository is used by default. Note that when you trying changing a repo, be aware that GITHUB_TOKEN
should also have permission for that repository.
Optional, You can set PAT here. If not set, this will use ${{ github.token }}
.
None
Feel free to report issues. 😃