diff --git a/types/config.ts b/types/config.ts index 6ba8c2d..1ef2f4f 100644 --- a/types/config.ts +++ b/types/config.ts @@ -60,7 +60,7 @@ export type Notification = { skipNotificationIds?: string[] } -export type WebhookConfig = { +type SingleWebhook = { url: string method?: 'GET' | 'POST' | 'PUT' | 'PATCH' headers?: { [key: string]: string | number } @@ -69,6 +69,8 @@ export type WebhookConfig = { timeout?: number } +export type WebhookConfig = SingleWebhook | SingleWebhook[] + export type Callbacks = { onStatusChange?: ( env: TEnv, diff --git a/worker/src/util.ts b/worker/src/util.ts index b5249b2..0cbe5ad 100644 --- a/worker/src/util.ts +++ b/worker/src/util.ts @@ -79,6 +79,13 @@ function templateWebhookPlayload(payload: any, message: string) { } async function webhookNotify(webhook: WebhookConfig, message: string) { + if (Array.isArray(webhook)) { + for (const w of webhook) { + webhookNotify(w, message) + } + return + } + console.log( 'Sending webhook notification: ' + JSON.stringify(message) + ' to webhook ' + webhook.url )