Skip to content

Commit

Permalink
Merge pull request #2 from szunami/szu/support-for-dedupe-key
Browse files Browse the repository at this point in the history
Support for dedupe key
  • Loading branch information
JohJonker authored Mar 19, 2021
2 parents 645dde3 + 29919c1 commit cae175f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Sends a critical PagerDuty alert, e.g. on action failure.

**Required:** the integration key for your PagerDuty service

`dedup_key`

**Optional:** a `dedup_key` for your alert. This will enable PagerDuty to coalesce multiple alerts into one.
More documentation is available [here](https://developer.pagerduty.com/docs/events-api-v2/trigger-events/).

## Example usage

In your `steps`:
Expand All @@ -25,4 +30,5 @@ In your `steps`:
uses: Entle/action-pagerduty-alert@0.1.0
with:
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}'
dedup_key: github_workflow_failed
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
pagerduty-integration-key:
description: 'The integration key for your PagerDuty service'
required: true
dedup_key:
description: 'The key used to correlate triggers, acknowledges, and resolves for the same alert.'
required: false
runs:
using: 'node12'
main: 'index.js'
Expand Down
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function sendAlert(alert) {
try {
const integrationKey = core.getInput('pagerduty-integration-key');

sendAlert({
let alert = {
payload: {
summary: `${context.repo.repo}: Error in "${context.workflow}" run by @${context.actor}`,
timestamp: new Date().toISOString(),
Expand All @@ -38,7 +38,12 @@ try {
},
routing_key: integrationKey,
event_action: 'trigger',
});
};
const dedup_key = core.getInput('dedup_key');
if (dedup_key != '') {
alert.dedup_key = dedup_key;
}
sendAlert(alert);
} catch (error) {
core.setFailed(error.message);
}

0 comments on commit cae175f

Please sign in to comment.