Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

PagerDuty Alert GitHub Action

A GitHub Action to send PagerDuty alerts for workflow status changes. Automatically triggers alerts on failures and resolves them on success.

Features

  • Automatic alert management: Triggers alerts on failure, resolves on success
  • Deduplication: Uses workflow run URL as dedup key to prevent duplicate alerts
  • Customizable: Configure severity, custom summaries, and more
  • Simple integration: Works with PagerDuty Events API v2

Usage

- name: Send PagerDuty Alert
  uses: kishankoushal/pagerduty-action@v1
  with:
    pagerduty_routing_key: ${{ secrets.PAGERDUTY_ROUTING_KEY }}
    run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
    job_status: ${{ job.status }}
    workflow_name: ${{ github.workflow }}

Complete Example

name: CI Pipeline

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Run tests
        run: npm test
      
      - name: Send PagerDuty Alert
        if: always()
        uses: kishankoushal/pagerduty-action@v1
        with:
          pagerduty_routing_key: ${{ secrets.PAGERDUTY_ROUTING_KEY }}
          run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
          job_status: ${{ job.status }}
          workflow_name: ${{ github.workflow }}
          severity: critical

Inputs

Input Description Required Default
pagerduty_routing_key PagerDuty Events API v2 routing key (integration key) Yes -
run_url URL of the GitHub workflow run (used as dedup_key) Yes -
job_status Status of the job (success/failure) Yes -
workflow_name Name of the workflow that triggered the alert Yes -
custom_summary Custom summary for the alert No Auto-generated
severity Alert severity for failures (critical/error/warning/info) No warning

Outputs

Output Description
status Status of the PagerDuty API response
message Message from PagerDuty API
dedup_key Deduplication key used for the alert
incident_key Incident key returned by PagerDuty API

Requirements

  • jq: Required for parsing JSON responses. Pre-installed on GitHub-hosted runners. For self-hosted runners, ensure jq is available.

Setup

1. Create a PagerDuty Service

  1. Go to ServicesService DirectoryNew Service
  2. Configure your service settings
  3. Select Events API V2 as the integration

2. Get the Routing Key

  1. Go to your service's Integrations tab
  2. Copy the Integration Key (this is your routing key)

3. Add Secret to GitHub

  1. Go to your repository SettingsSecrets and variablesActions
  2. Create a new secret named PAGERDUTY_ROUTING_KEY
  3. Paste your integration key

Behavior

  • On failure: Triggers a new PagerDuty incident with the specified severity
  • On success: Resolves any existing incident with the same dedup key
  • Deduplication: Uses the workflow run URL as the dedup key, ensuring the same run can trigger and resolve its own alerts

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors