generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 40
137 lines (117 loc) · 5.36 KB
/
alert_PD_schedule_Slack.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Find next person on call
on:
schedule:
- cron: "7 13 * * Tue-Fri" #UTC-5
- cron: "7 13 * * Mon" #UTC-5
env:
channel: prime-reportstream-engineering
jobs:
pre_job:
name: Pre Job
runs-on: ubuntu-latest
outputs:
IsMonday: ${{ steps.IsMonday.outputs.IsMonday }}
WeekDay: ${{ steps.WeekDay.outputs.IsWeekDay }}
steps:
- name: "Check out changes"
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: IsMonday
id: IsMonday
if: github.event_name == 'schedule' && github.event.schedule == '7 13 * * Mon'
shell: bash
run: echo "IsMonday=true" >> $GITHUB_OUTPUT
- name: IsWeekDay
id: WeekDay
if: github.event_name == 'schedule' && github.event.schedule == '7 13 * * Tue-Fri'
shell: bash
run: echo "IsWeekDay=true" >> $GITHUB_OUTPUT
PDAlert_Monday:
name: PD Alert for Monday
needs: pre_job
if: ${{ needs.pre_job.outputs.IsMonday == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Check Out Changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
with:
fetch-depth: 0
- name: Get PD oncall schedule
id: PD
shell: pwsh
run: |
./.github/scripts/PagerDutyAlerts/TriggerPDApi.ps1 -PD_KEY "${{ secrets.PD_ROTATION_SLACK_NOTIFICATION }}" -ScheduleIds "${{ secrets.PD_ReportStream_ScheduleId }}"
- name: Get PD onCall Details
id: PDOnCall
shell: pwsh
run: |
echo "${env:PDSchedules}" >> PDSchedules.json
- name: JSON to variables
uses: antifree/json-to-variables@8de3c6b94715a24fe65f29640b4e292a4add22a3
with:
filename: 'PDSchedules.json'
prefix: Schedules
- name: Slack Notification
uses: ./.github/actions/notifications
with:
method: slack
title: Pagerduty On-Call
message: |
"${{ env.Schedules_oncallSchedule_0_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_0_OnCallPersonName }}"* : _until_ \`"${{ env.Schedules_oncallSchedule_0_Until }}"\`
🔸"Next": *"${{ env.Schedules_oncallSchedule_0_NextPersonName }}"* : \`"${{ env.Schedules_oncallSchedule_0_NextFrom }}"\` _until_ \`"${{ env.Schedules_oncallSchedule_0_NextUntil }}"\`
"${{ env.Schedules_oncallSchedule_1_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_1_OnCallPersonName }}"* : _until_ \`"${{ env.Schedules_oncallSchedule_1_Until }}"\`
🔸"Next": *"${{ env.Schedules_oncallSchedule_1_NextPersonName }}"* : \`"${{ env.Schedules_oncallSchedule_1_NextFrom }}"\` _until_ \`"${{ env.Schedules_oncallSchedule_1_NextUntil }}"\`
"${{ env.Schedules_oncallSchedule_2_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_2_OnCallPersonName }}"* : _until_ \`"${{ env.Schedules_oncallSchedule_2_Until }}"\`
🔸"Next": *"${{ env.Schedules_oncallSchedule_2_NextPersonName }}"* : \`"${{ env.Schedules_oncallSchedule_2_NextFrom }}"\` _until_ \`"${{ env.Schedules_oncallSchedule_2_NextUntil }}"\`
"${{ env.Schedules_oncallSchedule_3_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_3_OnCallPersonName }}"* : _until_ \`"${{ env.Schedules_oncallSchedule_3_Until }}"\`
🔸"Next": *"${{ env.Schedules_oncallSchedule_3_NextPersonName }}"* : \`"${{ env.Schedules_oncallSchedule_3_NextFrom }}"\` _until_ \`"${{ env.Schedules_oncallSchedule_3_NextUntil }}"\`
icon-emoji: ':alarm_clock:'
channel: ${{ env.channel }}
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
color: good
PDAlert_WeekDays:
name: PD Alert for WeekDays
needs: pre_job
if: ${{ needs.pre_job.outputs.WeekDay == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Check Out Changes
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
with:
fetch-depth: 0
- name: Get PD oncall schedule
id: PD
shell: pwsh
run: |
./.github/scripts/PagerDutyAlerts/TriggerPDApi.ps1 -PD_KEY "${{ secrets.PD_ROTATION_SLACK_NOTIFICATION }}" -ScheduleIds "${{ secrets.PD_ReportStream_ScheduleId }}"
- name: Get PD onCall Details
id: PDOnCall
shell: pwsh
run: |
echo "${env:PDSchedules}" >> PDSchedules.json
- name: JSON to variables
uses: antifree/json-to-variables@8de3c6b94715a24fe65f29640b4e292a4add22a3
with:
filename: 'PDSchedules.json'
prefix: Schedules
- name: Slack Notification
uses: ./.github/actions/notifications
with:
method: slack
title: PagerDuty On-Call
message: |
"${{ env.Schedules_oncallSchedule_0_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_0_OnCallPersonName }}"*
"${{ env.Schedules_oncallSchedule_1_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_1_OnCallPersonName }}"*
"${{ env.Schedules_oncallSchedule_2_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_2_OnCallPersonName }}"*
"${{ env.Schedules_oncallSchedule_3_ScheduleName }}"
❗"Now": *"${{ env.Schedules_oncallSchedule_3_OnCallPersonName }}"*
icon-emoji: ':alarm_clock:'
channel: ${{ env.channel }}
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
color: good