-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (24 loc) · 1012 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
const github = require('@actions/github');
const core = require('@actions/core');
const main = async () => {
const token = core.getInput('token');
const approvalLabelsString = core.getInput('label-list');
const exclusionLabelsString = core.getInput('label-exclusion-list');
const octokit = github.getOctokit(token);
const { pull_request } = github.context.payload;
const { number, labels } = pull_request;
const prLabels = labels.map(label => label.name);
const approvalLabels = approvalLabelsString.split(',');
const exclusionLabels = (exclusionLabelsString && exclusionLabelsString.split(',')) || [];
if (
exclusionLabels.filter(exclusionLabel => prLabels.includes(exclusionLabel)).length === 0
&& approvalLabels.filter(approvalLabel => prLabels.includes(approvalLabel)).length > 0
) {
await octokit.rest.pulls.createReview({
...github.context.repo,
pull_number: number,
event: 'APPROVE'
});
}
};
main().catch(err => core.setFailed(err.message));