diff --git a/README.md b/README.md index 9d4a282..452b870 100644 --- a/README.md +++ b/README.md @@ -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() }} @@ -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/action-pagerduty-alert@0.5.0 + with: + pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}' + pagerduty-dedup-key: github_workflow_failed + event-type: resolve +``` diff --git a/action.yml b/action.yml index a9ca183..d6b5ab9 100644 --- a/action.yml +++ b/action.yml @@ -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' \ No newline at end of file + color: 'red' diff --git a/index.js b/index.js index 46da89c..f24c9fd 100644 --- a/index.js +++ b/index.js @@ -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: { @@ -37,7 +38,7 @@ try { }, }, routing_key: integrationKey, - event_action: 'trigger', + event_action: eventAction, }; const dedupKey = core.getInput('pagerduty-dedup-key'); if (dedupKey != '') {