-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
31 lines (28 loc) · 843 Bytes
/
index.js
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
require('dotenv').config()
const { Toolkit } = require('actions-toolkit')
const getAuthorNodeId = require('./lib/get-author-id')
const userIsSponsor = require('./lib/user-is-sponsor')
const createLabel = require('./lib/create-label')
const addLabel = require('./lib/add-label')
Toolkit.run(async tools => {
// Get the user id of the submitter
const nodeId = getAuthorNodeId(tools.context.payload)
// Check if the user is a sponsor
const isSponsor = await userIsSponsor(tools, nodeId)
if (!isSponsor) {
tools.log.debug('Author is not a sponsor! Nothing left to do.')
return
}
// Add the label
await createLabel(tools)
await addLabel(tools)
tools.log.success('Label successfully applied. Have a nice day!')
}, {
event: [
'pull_request.opened',
'issues.opened'
],
secrets: [
'GITHUB_TOKEN'
]
})