Skip to content

Commit ed0d094

Browse files
authored
feat: add support for multiple URLs of same client (#3)
* feat: add support for multiple urls of same client * feat: dist & bug fix * docs: updated docs * feat: comma separated values * fix: word improvement * fix: debug log
1 parent c169bfd commit ed0d094

File tree

6 files changed

+195
-106
lines changed

6 files changed

+195
-106
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
- uses: Netail/webhook-notifier@v1
3131
with:
3232
discord-url: 'https://discord.com/api/webhooks/...'
33-
slack-url: 'https://hooks.slack.com/services/...'
34-
teams-url: 'https://outlook.office.com/webhook/...'
33+
slack-url: 'https://hooks.slack.com/services/..., https://hooks.slack.com/services/...'
34+
teams-url: '["https://outlook.office.com/webhook/...", "https://outlook.office.com/webhook/..."]'
3535
color: 'info'
3636
title: '${{ github.event.pull_request.user.login }} opened PR-${{ github.event.number }} in ${{ github.event.repository.name }}'
3737
text: ${{ github.event.pull_request.title }}
@@ -46,10 +46,10 @@ The action has any of the follow inputs
4646
| Name | Description | Default | Notes |
4747
| - | - | - | - |
4848
| `dry-run` | Prevent sending the payload | false | |
49-
| `discord-url` | Discord Webhook URL | N/A | Discord does not support buttons in incoming webhooks, yet... |
50-
| `slack-url` | Slack Webhook URL | N/A | |
51-
| `teams-url` | Teams Webhook URL | N/A | Teams has deprecated giving colors to a card... |
52-
| `color` | Color of the message in hexadecimal or title of predefined | `success` | |
49+
| `discord-url` | Discord Webhook URL(s) | N/A | Optional: Can be comma separated values, or stringified JSON array of strings. Discord does not support buttons in incoming webhooks, yet |
50+
| `slack-url` | Slack Webhook URL(s) | N/A | Optional: Can be comma separated values, or stringified JSON array of strings. |
51+
| `teams-url` | Teams Webhook URL(s) | N/A | Optional: Can be comma separated values, or stringified JSON array of strings. Teams has deprecated colors in cards (temporarily) |
52+
| `color` | Color of the message | `success` | Value can be in hexadecimal or the title of a predefined color |
5353
| `title` | Text at the top of the message | `Hello world!` | |
5454
| `text` | Text to be displayed under the title | N/A | |
5555
| `fields` | Extra info to be displayed under the message | N/A | Stringified JSON array of objects with the attributes `name` and `value` ( e.g. `'[{"name": "string", "value": "string"}]'`) |

dist/index.js

Lines changed: 87 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers/send-payload.helper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const sendPayload = async (
1818
return { key, success: true };
1919
}
2020

21-
const response = await fetch(url, {
21+
const response = await fetch(url.trim(), {
2222
method: 'POST',
2323
body: JSON.stringify(payload),
2424
headers: {
@@ -27,17 +27,17 @@ export const sendPayload = async (
2727
});
2828

2929
if (response.ok) {
30-
debug(`Successfully sent ${key} payload to`);
30+
debug(`Successfully sent payload to ${key}`);
3131
return { key, success: true };
3232
} else {
3333
error(
34-
`Failed sending the ${key} payload to. API returned HTTP status ${response.status}`
34+
`Failed sending the payload to ${key}. API returned HTTP status ${response.status}`
3535
);
3636
return { key, success: false };
3737
}
3838
} catch (err) {
3939
if (err instanceof Error) {
40-
error(`Failed sending the ${key} payload to. Error:`, err.message);
40+
error(`Failed sending the payload to ${key}`);
4141
}
4242

4343
return { key, success: false };

0 commit comments

Comments
 (0)