Alert: Events from BinderHub build are not visible #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Resolve PagerDuty alert | |
| on: | |
| issues: | |
| types: [closed] | |
| jobs: | |
| parse-issue: | |
| if: > | |
| contains(github.event.issue.labels.*.name, 'pagerduty-alert') || | |
| contains(github.event.issue.labels.*.name, 'outage') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract incident ID from issue body | |
| id: extract | |
| shell: python | |
| run: | | |
| import os | |
| body = "${{ github.event.issue.body }}" | |
| output_file = os.getenv("GITHUB_OUTPUT") | |
| incident_match = re.search(r'/incidents/([A-Z0-9]+)', body) | |
| incident_id = incident_match.group(1) if incident_match else '' | |
| print(incident_id) | |
| with open(output_file, "a") as f: | |
| f.write(f"incident_id={incident_id}") | |
| - name: Leave a note to the incident | |
| uses: ./.github/actions/pagerduty-note | |
| with: | |
| incident_id: ${{ steps.extract.outputs.incident_id }} | |
| token: ${{ secrets.PD_TOKEN }} | |
| note_content: Solved in ${{ github.event.issue.html_url }} | |
| - name: Resolve incident | |
| env: | |
| ID: ${{ steps.extract.outputs.incident_id }} | |
| PD_TOKEN: ${{ secrets.PD_TOKEN }} | |
| run: |- | |
| curl --request PUT \ | |
| --url https://api.pagerduty.com/incidents/$ID \ | |
| --header "Accept: application/json" \ | |
| --header "Authorization: Token token=$PD_TOKEN" \ | |
| --header "Content-Type: application/json" \ | |
| --header "From: " \ | |
| --data '{ | |
| "incident": { | |
| "type": "incident_reference", | |
| "status": "resolved" | |
| } | |
| }' |