forked from DARMA-tasking/check-pr-fixes-issue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
57 lines (51 loc) · 1.28 KB
/
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
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
const core = require("@actions/core");
const helpers = require("./src/helpers");
async function check() {
try {
const prBranch = core.getInput("pr_branch");
const prTitle = core.getInput("pr_title");
const prDescription = core.getInput("pr_description");
if (helpers.checkPrBranch(prBranch) === false) {
core.setFailed("PR branch has wrong name");
return;
} else {
core.info(" - OK");
}
if (helpers.checkPrTitle(prTitle) === false) {
core.setFailed("PR title doesn't start with issue number");
return;
} else {
core.info(" - OK");
}
if (helpers.checkPrDescription(prDescription) == false) {
core.setFailed("PR description doesn't contain 'fixes #issue' phrase");
return;
} else {
core.info(" - OK");
}
if (
helpers.compareBranchTitleDescriptionIssueNumber(
prBranch,
prTitle,
prDescription
) === false
) {
core.setFailed(
"Branch name, PR title and PR description contain different issue numbers"
);
return;
} else {
core.info(" - OK");
}
} catch (error) {
core.error(error);
throw error;
}
}
(async () => {
try {
await check();
} catch (error) {
core.setFailed(error.message);
}
})();