-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify.js
More file actions
50 lines (44 loc) · 1 KB
/
Copy pathnotify.js
File metadata and controls
50 lines (44 loc) · 1 KB
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
const notifier = require('node-notifier')
const path = require('path')
const process = require('process')
const GITHUB_ICON = '' // FIXME add icon
function main(emailData) {
console.log('Email received, running notification...')
if (
!emailData.github ||
emailData.github.type !== 'action' ||
!emailData.github.pr
) {
return
}
const { organization, repository, name } = emailData.github
const { buildFailed, commit } = emailData.github.pr
if (
organization == null ||
repository == null ||
buildFailed == null ||
name == null ||
commit == null
) {
return
}
if (buildFailed) {
notifier.notify({
title: 'GitHub Action Run Failed\nvia Mailscript',
message:
'PR ' +
organization +
'/' +
repository +
' - ' +
name +
' (' +
commit +
')',
// icon: path.join(__dirname, GITHUB_ICON),
sound: true,
wait: false,
})
}
}
main(JSON.parse(process.env.payload))