Skip to content

Commit

Permalink
Add Client details and dedup key
Browse files Browse the repository at this point in the history
  • Loading branch information
ACyphus committed Jul 16, 2024
1 parent 48c0539 commit 617048d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,27 @@ jobs:
- name: Test
id: npm-ci-test
run: npm run ci-test

test-action:
name: Test pagerduty-send-event action
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
uses: ./
with:
pagerDutyRoutingKey: ${{ secrets.PAGERDUTY_TESTING_TOKEN }}
dedupKey: ${{ github.run_id }}
eventAction: trigger
summary: 'Test alert from ${ownerName}/${repoName} by ${actor}'
source: 'GitHub Actions in ${ownerName}/${repoName}'
severity: critical

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ inputs:
pagerDutyRoutingKey:
description: 'The PagerDuty Integration Key.'
required: true
dedupKey:
description:
'Identifies the alert to trigger, acknowledge, or resolve. Required unless
the event_type is trigger.'
required: false
eventAction:
description: 'The type of event. Can be trigger, acknowledge or resolve.'
required: true
Expand All @@ -28,6 +33,12 @@ inputs:
to the affected system.. Can be info, warning, error, or critical.'
required: true
default: 'critical'
clientUrl:
description:
'The URL of the monitoring client that is triggering this event. (This
field is only used for trigger events.)'
required: false
default: 'https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}'

# Define your outputs here.
outputs:
Expand Down
7 changes: 6 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ async function run() {
try {
// Get the inputs from the workflow file
const routingKey = core.getInput('pagerDutyRoutingKey', { required: true })
const dedupKey = core.getInput('dedupKey')
const eventAction = core.getInput('eventAction')
const summary = core.getInput('summary')
const source = core.getInput('source')
const severity = core.getInput('severity')
const clientUrl = core.getInput('clientUrl')

// Access GitHub context
const repoName = github.context.repo.repo
Expand All @@ -48,6 +50,7 @@ async function run() {
// Payload for PagerDuty Events API
const payload = {
event_action: eventAction,
dedup_key: dedupKey,
payload: {
summary: summary,

Check failure on line 55 in src/main.js

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 55 in src/main.js

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand
source: source,

Check failure on line 56 in src/main.js

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 56 in src/main.js

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand
Expand All @@ -62,7 +65,9 @@ async function run() {
actor: actor

Check failure on line 65 in src/main.js

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand

Check failure on line 65 in src/main.js

View workflow job for this annotation

GitHub Actions / Lint Codebase

Expected property shorthand
}
}
}
},
client: 'acyphus/pagerduty-send-event',
client_url: clientUrl
}

// Send a PagerDuty event
Expand Down

0 comments on commit 617048d

Please sign in to comment.