Skip to content

Commit

Permalink
fix: nofail=false does not raise error when webhook is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sarisia committed Jan 25, 2025
1 parent e823110 commit 48275de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ For `if` parameter, see
| noprefix | No | `true` or `false` | `false` | Set `true` to avoid appending job status (`Success: `, etc.) to title |
| nodetail | No | `true` or `false` | `false` | Set `true` will set both `nocontext` and `noprefix` to `true` |
| notimestamp | No | `true` or `false` | `false` | Set `true` to avoid appending timestamp |
| ack_no_webhook | No | `true` or `false` | `false` | Set `true` to suppress warnings when no Webhook endpoint is given |
| ack_no_webhook | No | `true` or `false` | `false` | Set `true` to suppress error which raised when webhook is not set |


<details>
Expand Down Expand Up @@ -184,8 +184,9 @@ You can modify payload before sending to Discord:
if: always()
id: webhook # set id to reference output payload later
with:
ack_no_webhook: true # set this to suppress warning
# you can omit webhook input (or DISCORD_WEBHOOK environment variable)
nofail: false
ack_no_webhook: true # set this to suppress error which is raised when nofail is disabled and webhook is not set
# webhook is not set here!
- run: npm install axios
- uses: actions/github-script@v7
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inputs:
required: false
default: "false"
ack_no_webhook:
description: "Suppress warning when webhook is not set"
description: "Suppress error which raised when webhook is not set"
required: false
default: "false"

Expand Down
2 changes: 1 addition & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function getInputs(): Inputs {

// validate
if (!inputs.webhooks.length && !inputs.ack_no_webhook) {
logWarning("No webhook is given. If this is intended, you can suppress this warning by setting `ack_no_webhook` to `true`.")
throw new Error("No webhook is given. If this is intended, you can suppress this error by setting `ack_no_webhook` to `true`.")
}
if (!(inputs.status in statusOpts)) {
throw new Error(`invalid status value: ${inputs.status}`)
Expand Down

0 comments on commit 48275de

Please sign in to comment.