From ec5aeb2009fe75d67d949e6aa0a682a7444302d0 Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 13 Aug 2024 12:30:19 +0200 Subject: [PATCH] :sparkles: Add custom webhook as notification option (#254) * Add custom webhook as notification option * Update src/helpers/notifme.ts Co-authored-by: Anand Chowdhary * Update src/helpers/notifme.ts Co-authored-by: Anand Chowdhary --------- Co-authored-by: Anand Chowdhary --- src/helpers/notifme.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/helpers/notifme.ts b/src/helpers/notifme.ts index ceb02891..41fa59f6 100644 --- a/src/helpers/notifme.ts +++ b/src/helpers/notifme.ts @@ -1,6 +1,6 @@ -import NotifmeSdk, { EmailProvider, SlackProvider, SmsProvider } from "notifme-sdk"; import axios from "axios"; import type { Channel } from "notifme-sdk"; +import NotifmeSdk, { EmailProvider, SlackProvider, SmsProvider } from "notifme-sdk"; import { replaceEnvironmentVariables } from "./environment"; import { getSecret } from "./secrets"; @@ -391,4 +391,23 @@ export const sendNotification = async (message: string) => { } console.log("Finished sending Microsoft Teams"); } + if (getSecret("NOTIFICATION_CUSTOM_WEBHOOK")) { + console.log("Sending Webhook"); + try { + await axios.post(`${getSecret("NOTIFICATION_CUSTOM_WEBHOOK_URL")}`,{ + data: { + message: JSON.stringify(message), + } + }, + { + headers: { + "Content-Type": "application/json", + }, + }); + console.log("Success Webhook"); + } catch (error) { + console.log("Got an error", error); + } + console.log("Finished sending Webhook"); + } };