mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
Allow message overrides for statuses (#62)
This commit is contained in:
parent
75079b41e7
commit
f116a1a828
10 changed files with 407 additions and 87 deletions
38
README.md
38
README.md
|
|
@ -12,6 +12,7 @@
|
|||
- Supports emoji 😂😂😂!
|
||||
- Supports a proxy for fork-based PRs. [See below](#proxy-for-fork-based-prs).
|
||||
- Supports creating a message from a file path.
|
||||
- Optional message / status overrides.
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
@ -66,13 +67,19 @@ jobs:
|
|||
| -------------------- | -------- | ---------------------------------------------------------------------------------------------------- | -------- | ------- |
|
||||
| message | with | The message you'd like displayed, supports Markdown and all valid Unicode characters. | maybe | |
|
||||
| message-path | with | Path to a message you'd like displayed. Will be read and displayed just like a normal message. | maybe | |
|
||||
| message-success | with | A message override, printed in case of success. | maybe | |
|
||||
| message-failure | with | A message override, printed in case of failure. | maybe | |
|
||||
| message-cancelled | with | A message override, printed in case of cancelled. | maybe | |
|
||||
| status | with | Required if you want to use message status overrides. | maybe | |
|
||||
| repo-token | with | Valid GitHub token, either the temporary token GitHub provides or a personal access token. | maybe | |
|
||||
| message-id | with | Message id to use when searching existing comments. If found, updates the existing (sticky comment). | no | |
|
||||
| allow-repeats | with | Boolean flag to allow identical messages to be posted each time this action is run. | no | false |
|
||||
| proxy-url | with | String for your proxy service URL if you'd like this to work with fork-based PRs. | no | |
|
||||
| GITHUB_TOKEN | env | Valid GitHub token, can alternatively be defined in the env. | maybe | |
|
||||
|
||||
## Proxy for Fork-based PRs
|
||||
## Advanced Uses
|
||||
|
||||
### Proxy for Fork-based PRs
|
||||
|
||||
GitHub limits `GITHUB_TOKEN` and other API access token permissions when creating a PR from a fork. This precludes adding comments when your PRs are coming from forks, which is the norm for open source projects. To work around this situation I've created a simple companion app you can deploy to Cloud Run or another host to proxy the create comment requests with a personal access token you provide.
|
||||
|
||||
|
|
@ -99,3 +106,32 @@ jobs:
|
|||
proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Status Message Overrides
|
||||
|
||||
You can override your messages based on your job status. This can be helpful
|
||||
if you don't anticipate having the data required to create a helpful message in
|
||||
case of failure, but you still want a message to be sent to the PR comment.
|
||||
|
||||
**Example**
|
||||
|
||||
```yaml
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: mshick/add-pr-comment@v2
|
||||
with:
|
||||
if: always()
|
||||
message: |
|
||||
**Howdie!**
|
||||
message-failure: |
|
||||
Uh oh!
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue