generated from sigstore/sigstore-project-template
96 lines (89 loc) · 3.42 KB
/
reusable-pager.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: 'PagerDuty: Trigger Alert'
on:
workflow_call:
secrets:
PAGERDUTY_INTEGRATION_KEY:
description: 'Integration key for PagerDuty'
required: true
inputs:
retries:
description: 'The number of times to retry sending a page on an intermittent error (e.g. HTTP 429, 500 response codes); note exponential backoff is in use'
type: number
default: 4
summary:
description: 'A brief text summary of the event, used to generate the summaries/titles of any associated alerts. The maximum permitted length of this property is 1024 characters.'
default: 'unknown'
type: string
source:
description: 'The unique location of the affected system, preferably a hostname or FQDN.'
default: 'GitHub Actions Prober'
type: string
severity:
description: 'The perceived severity of the status the event is describing with respect to the affected system. This can be "critical", "error", "warning" or "info".'
default: 'error'
type: string
component:
description: 'Component of the infrastructure that is responsible for the event, for example "rekor" or "fulcio"'
required: true
type: string
group:
description: 'Logical grouping of components of a service, for example "production" or "staging"'
required: true
type: string
details:
description: 'Additional details about the event and affected system; specified as a stringified JSON object'
type: string
links:
description: 'Relevant links for the event and affected system; specified as a stringified JSON array of objects of schema {"href":"http://google.com","text":"optional description"}'
type: string
permissions:
contents: read
jobs:
pagerduty-notification:
timeout-minutes: 10
name: PagerDuty Notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v3.3.0
with:
go-version: '1.21'
check-latest: true
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: detailsAndLinks
env:
DETAILS: ${{ inputs.details }}
LINKS: ${{ inputs.links }}
with:
result-encoding: string
script: |
const { DETAILS, LINKS } = process.env;
let output = ",";
if (DETAILS !== "") {
output += '\n "details": ' + DETAILS;
if (LINKS !== "") {
output += ',';
}
}
if (LINKS !== "") {
output += '\n "links": ' + LINKS;
}
if (output.length == 1) {
output = "";
}
return output;
- name: Pagerduty Notification
shell: bash
env:
PAGERDUTY_INTEGRATION_KEY: ${{ secrets.PAGERDUTY_INTEGRATION_KEY }}
run: |
cd pager-duty
go run main.go --retry-count ${{ inputs.retries }} <<EOF
{
"summary": "${{ inputs.summary }}",
"source": "${{ inputs.source }}",
"severity": "${{ inputs.severity }}",
"component": "${{ inputs.component }}",
"group": "${{ inputs.group }}"${{ steps.detailsAndLinks.outputs.result }}
}
EOF