https://github.com/miry/prcomment
Update or create a new comment to PR or Issue.
https://github.com/miry/prcomment
Last synced: 10 months ago
JSON representation
Update or create a new comment to PR or Issue.
- Host: GitHub
- URL: https://github.com/miry/prcomment
- Owner: miry
- License: lgpl-3.0
- Created: 2019-08-04T16:46:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-10T21:50:05.000Z (over 2 years ago)
- Last Synced: 2025-04-22T12:19:12.414Z (about 1 year ago)
- Language: Crystal
- Size: 41 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://stand-with-ukraine.pp.ua/)
# PRCOMMENT
[](https://github.com/miry/prcomment/releases)
[](https://raw.githubusercontent.com/miry/prcomment/master/LICENSE)
[](https://stand-with-ukraine.pp.ua)
[](https://stand-with-ukraine.pp.ua)
Creates or updates single comment to Github PR or Issue.
# Usage
First step is generate a new Github token in [Github Settings](https://github.com/settings/tokens/new?description=prcomment&scopes=public_repo).
## Binaries
```shell
export GITHUB_TOKEN=
prcomment -i 1 -r miry/prcomment Hello from console
```
## Docker
```shell
docker run -e GITHUB_TOKEN= --rm -it ghcr.io/miry/prcomment:0.1.3 -i 1 -r miry/prcomment Hello
```
## Crystal
```shell
export GITHUB_TOKEN=
crystal run src/cli.cr -- -i 1 -r miry/prcomment Hello
```
## GithubAction
### Inputs
### msg
**Required** The msg of the comment. Default `"World"`.
### pr
**Optional** The PR or Issue ID where to add a comment. Default `github.event.pull_request.number`.
### match
**Optional** Pattern of the comment to be replaced with. Default `""`
### Examples
```yml
steps:
-
uses: miry/prcomment@v0.1.3
if: github.event_name == 'pull_request'
name: Comment
with:
msg: "Testing simple message from job ${{ github.run_id }}!"
match: 'Testing simple message from job .*'
pr: ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}
```
# Options
## Match
One of the cases to have comment to show current test coverage.
By default, `prcomment` looks for first comment with same text.
```shell
crystal run src/cli.cr -- -i 1 -r miry/prcomment -m "Test coverage \d*%" Test coverage 80% # Creates a comment with text: 'Test coverage 80%'
crystal run src/cli.cr -- -i 1 -r miry/prcomment -m "Test coverage \d*%" Test coverage 130% # Finds the comment and replaces with: 'Test coverage 130%'
```
It is also usefull to change previous answer with new one:
```shell
crystal run src/cli.cr -- -i 1 -r miry/prcomment -m ":[+-]1:" ":+1:" # Creates a comment with icon: ':+1'
crystal run src/cli.cr -- -i 1 -r miry/prcomment -m ":[+-]1:" ":-1:" # Replaces with ':-1:'
```
The comment is too big for single line:
```shell
echo "The big content could be piped\nSome pattern from the comment\nThird line" | \
crystal run src/cli.cr -- -i 1 -r miry/prcomment -m "Some pattern from the comment"
```