forked from probot/example-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (24 loc) · 917 Bytes
/
app.js
File metadata and controls
28 lines (24 loc) · 917 Bytes
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
/**
* @param {import('probot').Probot} app
*/
const check = require('./src/checks');
module.exports = (app) => {
app.log("\n\n\nPR Format Checker loaded, put 'URGENT' in PR title to skip this check!\n\n\n");
app.on(["pull_request.opened", "pull_request.edited", "pull_request.reopened"], async (context) => {
let pr = await context.octokit.pulls.get(context.pullRequest())
pr = context.payload.pull_request
// for urgent, just skip this check
if (pr.title.indexOf("URGENT") >= 0) {
app.log("for URGENT, skip!")
return
}
const checkItems = ["lineChanges", "jiraTitle", "body", "tasks"]
let checkResults = check(pr, checkItems)
checkResults.forEach((checkR, index) => {
context.log(`[${checkItems[index]}]: ${checkR}`)
})
if (checkResults.filter(cr => cr === false).length !== 0) {
throw ["PR Format check failure, please check!"]
}
});
}