PagerDuty Change Events & GitHub Actions
By jjm
Following on from Managing PagerDuty Services With Terraform, another rather nice PagerDuty feature is Change Events. This was release at last years PagerDuty Summit. Which I started making use of these a few months ago, as they add some additional context around possible changes that were deployed that could be relevant for incidents on the service.
Using them is in GitHub is really simple, first you just need to add the integration to the service. Being on building on the Terraform in the previous post, it’s just adding another data source and resource to your Terraform:
data "pagerduty_vendor" "github" {
name = "GitHub"
}
resource "pagerduty_service_integration" "github" {
name =data.pagerduty_vendor.github.name
vendor = data.pagerduty_vendor.github.id
service = pagerduty_service.blog.id
}
Then when you have deployed this, it’s just a case of adding another workflow to GitHub. I’ve been adding these a separate workflow, given that pull_request
only being for closed PRs and you’ll want this trigger ASAP following the push / merge:
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- closed
jobs:
send-pd-change-event:
runs-on: ubuntu-latest
name: Send PagerDuty Change Event
steps:
- name: Create a change event
uses: PagerDuty/pagerduty-change-events-action@master
with:
integration-key: ${{ secrets.PAGERDUTY_CHANGE_INTEGRATION_KEY }}
This has a few changes over the current example (and 1 fix). So now every time a PR is closed (and a push happens), you will see a change event in PagerDuty for this service. It’s work noting you get way more information when Pull Request has been closed over when a push happens.