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

implement possibility to automatically resolve alerts #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ Sends a critical PagerDuty alert, e.g. on action failure.
**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/).

`event-type`

**Optional:** Can be used to resolve an alert when used together with `pagerduty-dedup-key`.

## Example usage

In your `steps`:

### Trigger a PagerDuty alert

```yaml
- name: Send PagerDuty alert on failure
if: ${{ failure() }}
Expand All @@ -32,3 +38,14 @@ In your `steps`:
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}'
pagerduty-dedup-key: github_workflow_failed
```

### Resolve a PagerDuty alert

```yaml
- name: Resolve PagerDuty alert when CI succeeds
uses: Entle/[email protected]
with:
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}'
pagerduty-dedup-key: github_workflow_failed
event-type: resolve
```
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ inputs:
pagerduty-dedup-key:
description: 'The key used to correlate PagerDuty triggers, acknowledges, and resolves for the same alert.'
required: false
event-type:
description: 'Trigger or resolve this alert? Default is trigger (Valid values: trigger, resolve)'
default: 'trigger'
required: false
runs:
using: 'node12'
main: 'index.js'
branding:
icon: 'alert-triangle'
color: 'red'
color: 'red'
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async function sendAlert(alert) {
// Run the action
try {
const integrationKey = core.getInput('pagerduty-integration-key');
const eventAction = core.getInput('event-type');

let alert = {
payload: {
Expand All @@ -37,7 +38,7 @@ try {
},
},
routing_key: integrationKey,
event_action: 'trigger',
event_action: eventAction,
};
const dedupKey = core.getInput('pagerduty-dedup-key');
if (dedupKey != '') {
Expand Down