-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathassign-pr-reviewers.js
More file actions
82 lines (80 loc) · 2.15 KB
/
assign-pr-reviewers.js
File metadata and controls
82 lines (80 loc) · 2.15 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {
notifyUser
} from "../main-1fa4935b.js";
import"../main-bd6vw39p.js";
import"../main-dkdfy8cx.js";
import {
CORE_APPROVED_PR_LABEL
} from "../main-9c2herm2.js";
import {
getCoreMemberLogins
} from "../main-fb6evf2x.js";
import"../main-mycz0558.js";
import {
require_lodash
} from "../main-pet5htdh.js";
import {
require_bluebird
} from "../main-ttmzs6m5.js";
import {
HelperInputs
} from "../main-8h70j5cy.js";
import {
octokit
} from "../main-4c5nddsb.js";
import {
context
} from "../main-6avxv4a6.js";
import"../main-9m3k9gt0.js";
import {
info
} from "../main-q70tmm6g.js";
import {
__toESM
} from "../main-wckvcay0.js";
// src/helpers/assign-pr-reviewers.ts
var import_bluebird = __toESM(require_bluebird(), 1);
var import_lodash = __toESM(require_lodash(), 1);
class AssignPrReviewer extends HelperInputs {
}
var assignPrReviewers = async ({
teams,
login,
number_of_assignees = "1",
slack_webhook_url,
pull_number = String(context.issue.number)
}) => {
const coreMemberLogins = await getCoreMemberLogins({ pull_number: context.issue.number, teams: teams?.split(`
`) });
const {
data: { user, labels }
} = await octokit.pulls.get({ pull_number: context.issue.number, ...context.repo });
if (login && coreMemberLogins.includes(login)) {
info("Already a core member, no need to assign.");
return;
}
if (labels?.find((label) => label.name === CORE_APPROVED_PR_LABEL)) {
info("Already approved by a core member, no need to assign.");
return;
}
const prAuthorUsername = user?.login;
const filteredCoreMemberLogins = coreMemberLogins.filter((userName) => userName !== prAuthorUsername);
const assignees = import_lodash.sampleSize(filteredCoreMemberLogins, Number(number_of_assignees));
await octokit.issues.addAssignees({
assignees,
issue_number: Number(pull_number),
...context.repo
});
if (slack_webhook_url) {
await import_bluebird.map(assignees, async (assignee) => notifyUser({
login: assignee,
pull_number: Number(pull_number),
slack_webhook_url
}), { concurrency: 1 });
}
};
export {
assignPrReviewers,
AssignPrReviewer
};
//# debugId=5374D441971C908864756E2164756E21