diff --git a/action.yml b/action.yml index 1a6b598c..5e892f0e 100644 --- a/action.yml +++ b/action.yml @@ -10,12 +10,8 @@ inputs: description: 'Slack Webhook URL. More info: https://api.slack.com/messaging/webhooks' pager_duty_integration_key: description: 'Pager Duty Integration Key. More info: https://support.pagerduty.com/docs/services-and-integrations' - zenduty_api_key: - description: 'Create a Zenduty API Key by visiting Account Settings > API Keys' - zenduty_service_id: - description: 'Zenduty Service ID: https://docs.zenduty.com/docs/services' - zenduty_escalation_policy_id: - description: 'Zenduty Escalation Policy ID: https://docs.zenduty.com/docs/escalationpolicies' + zenduty_integration_key: + description: 'Zenduty native api integration key. More info: https://docs.zenduty.com/docs/api' email_from: description: 'Sender email' email_list: diff --git a/src/destinations/zenduty.ts b/src/destinations/zenduty.ts index 8dfbad2d..fd3621f0 100644 --- a/src/destinations/zenduty.ts +++ b/src/destinations/zenduty.ts @@ -3,9 +3,7 @@ import { Alert } from '../entities' import { request } from '../utils' export const sendAlertsToZenduty = async ( - apiKey: string, - serviceId: string, - escalationPolicyId: string, + zenDutyIntegrationKey: string, alerts: Alert[], ): Promise => { let summary = ` @@ -29,17 +27,13 @@ export const sendAlertsToZenduty = async ( --- ` const payload = { - service: serviceId, - escalation_policy: escalationPolicyId, - title: `${ACTION_SHORT_SUMMARY} - ${alerts[0].repository.name}`, - urgency: 0, - summary, + alert_type: "critical", + message: `${ACTION_SHORT_SUMMARY} - ${alerts[0].repository.name}` , + summary: summary, } - const bearer = `Token ${apiKey}` - await request('https://www.zenduty.com/api/incidents/', { + await request('https://www.zenduty.com/api/events/${zenDutyIntegrationKey}/', { method: 'POST', headers: { - Authorization: bearer, 'Content-Type': 'application/json', }, body: JSON.stringify(payload), diff --git a/src/main.ts b/src/main.ts index 31d5d863..05a2ccd7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,9 +16,7 @@ async function run(): Promise { const microsoftTeamsWebhookUrl = getInput('microsoft_teams_webhook') const slackWebhookUrl = getInput('slack_webhook') const pagerDutyIntegrationKey = getInput('pager_duty_integration_key') - const zenDutyApiKey = getInput('zenduty_api_key') - const zenDutyServiceId = getInput('zenduty_service_id') - const zenDutyEscalationPolicyId = getInput('zenduty_escalation_policy_id') + const zenDutyIntegrationKey= getInput('zenduty_integration_key') const emailFrom = getInput('email_from') const emailList = getInput('email_list') const emailSubject = getInput('email_subject') @@ -46,19 +44,8 @@ async function run(): Promise { if (pagerDutyIntegrationKey) { await sendAlertsToPagerDuty(pagerDutyIntegrationKey, alerts) } - if (zenDutyApiKey) { - if (zenDutyServiceId && zenDutyEscalationPolicyId) { - await sendAlertsToZenduty( - zenDutyApiKey, - zenDutyServiceId, - zenDutyEscalationPolicyId, - alerts, - ) - } else { - setFailed( - new Error('Check your Zenduty Service ID and Escalation Policy ID'), - ) - } + if (zenDutyIntegrationKey) { + await sendAlertsToZenduty(zenDutyIntegrationKey, alerts) } if (emailFrom && emailList) { const emailWikiLink =