Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for multiple URLs of same client #3

Merged
merged 6 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- uses: Netail/webhook-notifier@v1
with:
discord-url: 'https://discord.com/api/webhooks/...'
slack-url: 'https://hooks.slack.com/services/...'
teams-url: 'https://outlook.office.com/webhook/...'
slack-url: 'https://hooks.slack.com/services/..., https://hooks.slack.com/services/...'
teams-url: '["https://outlook.office.com/webhook/...", "https://outlook.office.com/webhook/..."]'
color: 'info'
title: '${{ github.event.pull_request.user.login }} opened PR-${{ github.event.number }} in ${{ github.event.repository.name }}'
text: ${{ github.event.pull_request.title }}
Expand All @@ -46,10 +46,10 @@ The action has any of the follow inputs
| Name | Description | Default | Notes |
| - | - | - | - |
| `dry-run` | Prevent sending the payload | false | |
| `discord-url` | Discord Webhook URL | N/A | Discord does not support buttons in incoming webhooks, yet... |
| `slack-url` | Slack Webhook URL | N/A | |
| `teams-url` | Teams Webhook URL | N/A | Teams has deprecated giving colors to a card... |
| `color` | Color of the message in hexadecimal or title of predefined | `success` | |
| `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 |
| `slack-url` | Slack Webhook URL(s) | N/A | Optional: Can be comma separated values, or stringified JSON array of strings. |
| `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) |
| `color` | Color of the message | `success` | Value can be in hexadecimal or the title of a predefined color |
| `title` | Text at the top of the message | `Hello world!` | |
| `text` | Text to be displayed under the title | N/A | |
| `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"}]'`) |
Expand Down
130 changes: 87 additions & 43 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/helpers/send-payload.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const sendPayload = async (
return { key, success: true };
}

const response = await fetch(url, {
const response = await fetch(url.trim(), {
method: 'POST',
body: JSON.stringify(payload),
headers: {
Expand All @@ -27,17 +27,17 @@ export const sendPayload = async (
});

if (response.ok) {
debug(`Successfully sent ${key} payload to`);
debug(`Successfully sent payload to ${key}`);
return { key, success: true };
} else {
error(
`Failed sending the ${key} payload to. API returned HTTP status ${response.status}`
`Failed sending the payload to ${key}. API returned HTTP status ${response.status}`
);
return { key, success: false };
}
} catch (err) {
if (err instanceof Error) {
error(`Failed sending the ${key} payload to. Error:`, err.message);
error(`Failed sending the payload to ${key}`);
}

return { key, success: false };
Expand Down
Loading
Loading