Skip to content

Commit 42ae7eb

Browse files
committed
Package maintenance and improvement to VALIDATE_SEAT_ASSIGNMENT
1 parent bf6bbd6 commit 42ae7eb

File tree

4 files changed

+229
-737
lines changed

4 files changed

+229
-737
lines changed

index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,21 @@ module.exports = (app) => {
8787
app.log.info(fileContent);
8888

8989
// create an issue using fileContent as body if pr_author is included in copilotSeats using Copilot Seat Billing api
90-
let copilotSeats = await context.octokit.request(
91-
"GET /orgs/{org}/copilot/billing/seats",
92-
{
93-
org: organization_name,
94-
headers: {
95-
'X-GitHub-Api-Version': '2022-11-28'
90+
let copilotSeatUsers = [];
91+
if (VALIDATE_SEAT_ASSIGNMENT == "YES") {
92+
let copilotSeats = await context.octokit.request(
93+
"GET /orgs/{org}/copilot/billing/seats",
94+
{
95+
org: organization_name,
96+
headers: {
97+
'X-GitHub-Api-Version': '2022-11-28'
98+
}
9699
}
97-
}
98-
);
99-
let copilotSeatUsers = copilotSeats.data.seats;
100+
);
101+
copilotSeatUsers = copilotSeats.data.seats;
102+
}
100103

101-
if ( (Boolean(VALIDATE_SEAT_ASSIGNMENT) && copilotSeatUsers.some(user => user.assignee.login == pr_author)) || !Boolean(VALIDATE_SEAT_ASSIGNMENT)) {
104+
if ( VALIDATE_SEAT_ASSIGNMENT != "YES" || (VALIDATE_SEAT_ASSIGNMENT == "YES" && copilotSeatUsers.some(user => user.assignee.login == pr_author))) {
102105
try {
103106
await context.octokit.issues.create({
104107
owner: organization_name,

0 commit comments

Comments
 (0)