mirror of
https://github.com/mshick/add-pr-comment.git
synced 2026-01-01 22:49:45 +11:00
parent
5cc4621415
commit
f8c324a9fc
9 changed files with 502 additions and 90 deletions
132
README.md
132
README.md
|
|
@ -1,7 +1,9 @@
|
|||
# add-pr-comment
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
|
||||
[](#contributors-)
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
A GitHub Action which adds a comment to a pull request's issue.
|
||||
|
|
@ -168,6 +170,136 @@ jobs:
|
|||
message-part-*.txt
|
||||
```
|
||||
|
||||
### Find-and-Replace
|
||||
|
||||
Patterns can be matched and replaced to update comments. This could be useful
|
||||
for some situations, for instance, updating a checklist comment.
|
||||
|
||||
Find is a regular expression passed to the [RegExp() constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp). You can also
|
||||
include modifiers to override the default `gi`.
|
||||
|
||||
**Example**
|
||||
|
||||
Original message:
|
||||
|
||||
```
|
||||
[ ] Hello
|
||||
[ ] World
|
||||
```
|
||||
|
||||
Action:
|
||||
|
||||
```yaml
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: mshick/add-pr-comment@v2
|
||||
if: always()
|
||||
with:
|
||||
find: |
|
||||
\n\\[ \\]
|
||||
replace: |
|
||||
[X]
|
||||
```
|
||||
|
||||
Final message:
|
||||
|
||||
```
|
||||
[X] Hello
|
||||
[X] World
|
||||
```
|
||||
|
||||
Multiple find and replaces can be used:
|
||||
|
||||
**Example**
|
||||
|
||||
Original message:
|
||||
|
||||
```
|
||||
hello world!
|
||||
```
|
||||
|
||||
Action:
|
||||
|
||||
```yaml
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: mshick/add-pr-comment@v2
|
||||
if: always()
|
||||
with:
|
||||
find: |
|
||||
hello
|
||||
world
|
||||
replace: |
|
||||
goodnight
|
||||
moon
|
||||
```
|
||||
|
||||
Final message:
|
||||
|
||||
```
|
||||
goodnight moon!
|
||||
```
|
||||
|
||||
It defaults to your resolved message (either from `message` or `message-path`) to
|
||||
do a replacement:
|
||||
|
||||
**Example**
|
||||
|
||||
Original message:
|
||||
|
||||
```
|
||||
hello
|
||||
|
||||
<< FILE_CONTENTS >>
|
||||
|
||||
world
|
||||
```
|
||||
|
||||
Action:
|
||||
|
||||
```yaml
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: mshick/add-pr-comment@v2
|
||||
if: always()
|
||||
with:
|
||||
message-path: |
|
||||
message.txt
|
||||
find: |
|
||||
<< FILE_CONTENTS >>
|
||||
```
|
||||
|
||||
Final message:
|
||||
|
||||
```
|
||||
hello
|
||||
|
||||
secret message from message.txt
|
||||
|
||||
world
|
||||
```
|
||||
|
||||
### Bring your own issues
|
||||
|
||||
You can set an issue id explicitly. Helpful for cases where you want to post
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue