Compare commits

...

10 Commits

Author SHA1 Message Date
0bc3ec0e0a use graphql api to request team reviews 2023-03-30 15:46:36 +09:00
36a56dac07 build(deps-dev): bump @typescript-eslint/parser from 5.56.0 to 5.57.0 (#1768)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.56.0 to 5.57.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.57.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-28 13:09:36 +00:00
b7f0c9773b build(deps-dev): bump prettier from 2.8.6 to 2.8.7 (#1767)
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.6 to 2.8.7.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.6...2.8.7)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-28 13:00:54 +00:00
6a62596740 build(deps): bump peter-evans/enable-pull-request-automerge from 2 to 3 (#1766)
Bumps [peter-evans/enable-pull-request-automerge](https://github.com/peter-evans/enable-pull-request-automerge) from 2 to 3.
- [Release notes](https://github.com/peter-evans/enable-pull-request-automerge/releases)
- [Commits](https://github.com/peter-evans/enable-pull-request-automerge/compare/v2...v3)

---
updated-dependencies:
- dependency-name: peter-evans/enable-pull-request-automerge
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-28 13:00:35 +00:00
d1ed29fe1e build(deps-dev): bump @types/node from 18.15.5 to 18.15.10 (#1765)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.15.5 to 18.15.10.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-28 13:00:32 +00:00
e34fedf492 build(deps-dev): bump eslint-plugin-github from 4.6.1 to 4.7.0 (#1764)
Bumps [eslint-plugin-github](https://github.com/github/eslint-plugin-github) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/github/eslint-plugin-github/releases)
- [Commits](https://github.com/github/eslint-plugin-github/compare/v4.6.1...v4.7.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-github
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-28 13:00:07 +00:00
495ffbb489 build(deps-dev): bump @types/node from 18.15.3 to 18.15.5 (#1744)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.15.3 to 18.15.5.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-21 13:06:09 +00:00
073c8e6ece build(deps-dev): bump @types/jest from 29.4.1 to 29.5.0 (#1742)
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.4.1 to 29.5.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: "@types/jest"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-21 13:00:37 +00:00
375254568c build(deps-dev): bump @typescript-eslint/parser from 5.55.0 to 5.56.0 (#1743)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.55.0 to 5.56.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.56.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-21 13:00:16 +00:00
09af4e30b5 build(deps-dev): bump prettier from 2.8.4 to 2.8.6 (#1741)
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.4 to 2.8.6.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.4...2.8.6)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-21 12:59:51 +00:00
5 changed files with 325 additions and 89 deletions

View File

@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: peter-evans/enable-pull-request-automerge@v2
- uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
pull-request-number: ${{ github.event.pull_request.number }}

103
dist/index.js vendored
View File

@ -1074,10 +1074,10 @@ class GitHubHelper {
requestReviewersParams['reviewers'] = inputs.reviewers;
core.info(`Requesting reviewers '${inputs.reviewers}'`);
}
if (inputs.teamReviewers.length > 0) {
requestReviewersParams['team_reviewers'] = inputs.teamReviewers;
core.info(`Requesting team reviewers '${inputs.teamReviewers}'`);
}
// if (inputs.teamReviewers.length > 0) {
// requestReviewersParams['team_reviewers'] = inputs.teamReviewers
// core.info(`Requesting team reviewers '${inputs.teamReviewers}'`)
// }
if (Object.keys(requestReviewersParams).length > 0) {
try {
yield this.octokit.rest.pulls.requestReviewers(Object.assign(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pull.number }), requestReviewersParams));
@ -1091,9 +1091,104 @@ class GitHubHelper {
}
}
}
const orgs = inputs.teamReviewers.map(team => {
if (!team.includes('/')) {
throw new Error(`Team ${team} is not in the correct format. It should be in the format org/team`);
}
return team.split('/')[0];
});
const distinctOrgs = [...new Set(orgs)];
core.debug(`distinctOrgs: ${distinctOrgs}`);
const orgTeams = yield Promise.all(distinctOrgs.map(org => this.getOrgTeams(org)));
const teamIds = inputs.teamReviewers.map(team => {
var _a;
const [org, teamName] = team.split('/');
const orgTeam = orgTeams.find(orgTeam => orgTeam.organization.login === org);
if (!orgTeam) {
throw new Error(`Org ${org} not found`);
}
const teamId = (_a = orgTeam.organization.teams.edges.find(team => team.node.slug === teamName)) === null || _a === void 0 ? void 0 : _a.node.id;
if (!teamId) {
throw new Error(`Team ${teamName} not found in ${org}`);
}
return teamId;
});
core.debug(`teamIds: ${teamIds}`);
if (teamIds.length > 0) {
const repository = this.parseRepository(baseRepository);
const pullNodeId = yield this.getPullNodeId(repository.owner, repository.repo, pull.number);
core.debug(`pullNodeId: ${pullNodeId}`);
yield this.requestReviewers(pullNodeId, teamIds);
}
return pull;
});
}
getOrgTeams(orgName) {
return __awaiter(this, void 0, void 0, function* () {
const query = `
query($orgName: String!, $teamCount: Int!) {
organization(login: $orgName) {
login
teams(first: $teamCount) {
edges {
node {
id
slug
}
}
}
}
}
`;
const teamCount = 100;
return this.octokit.graphql(query, {
orgName,
teamCount
});
});
}
getPullNodeId(owner, repo, pullNumber) {
return __awaiter(this, void 0, void 0, function* () {
const query = `
query($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: ${pullNumber}) {
id
}
}
}
`;
return (yield this.octokit.graphql(query, {
owner,
repo
})).repository.pullRequest.id;
});
}
requestReviewers(pullRequestId, teamIds) {
return __awaiter(this, void 0, void 0, function* () {
const mutation = `
mutation($input: RequestReviewsInput!) {
requestReviews(input: $input) {
clientMutationId
}
}
`;
yield this.octokit
.graphql(mutation, {
input: {
pullRequestId,
teamIds: teamIds,
union: true
}
})
.then(response => {
core.info('Reviews requested successfully');
})
.catch(error => {
core.error(error);
});
});
}
}
exports.GitHubHelper = GitHubHelper;

150
package-lock.json generated
View File

@ -18,20 +18,20 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/jest": "^29.4.1",
"@types/node": "^18.15.3",
"@typescript-eslint/parser": "^5.55.0",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.10",
"@typescript-eslint/parser": "^5.57.0",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.36.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-github": "^4.6.1",
"eslint-plugin-github": "^4.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"jest": "^29.5.0",
"jest-circus": "^29.4.2",
"jest-environment-jsdom": "^29.5.0",
"js-yaml": "^4.1.0",
"prettier": "^2.8.4",
"prettier": "^2.8.7",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
}
@ -1523,9 +1523,9 @@
}
},
"node_modules/@types/jest": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.1.tgz",
"integrity": "sha512-zDQSWXG+ZkEvs2zFFMszePhx4euKz+Yt3Gg1P+RHjfJBinTTr6L2DEyovO4V/WrKXuF0Dgn56GWGZPDa6TW9eQ==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.0.tgz",
"integrity": "sha512-3Emr5VOl/aoBwnWcH/EFQvlSAmjV+XtV9GGu5mwdYew5vhQh0IUZx/60x0TzHDu09Bi7HMx10t/namdJw5QIcg==",
"dev": true,
"dependencies": {
"expect": "^29.0.0",
@ -1556,9 +1556,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "18.15.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.3.tgz",
"integrity": "sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==",
"version": "18.15.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.10.tgz",
"integrity": "sha512-9avDaQJczATcXgfmMAW3MIWArOO7A+m90vuCFLr8AotWf8igO/mRoYukrk2cqZVtv38tHs33retzHEilM7FpeQ==",
"dev": true
},
"node_modules/@types/prettier": {
@ -1673,14 +1673,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.55.0.tgz",
"integrity": "sha512-ppvmeF7hvdhUUZWSd2EEWfzcFkjJzgNQzVST22nzg958CR+sphy8A6K7LXQZd6V75m1VKjp+J4g/PCEfSCmzhw==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.0.tgz",
"integrity": "sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.55.0",
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/typescript-estree": "5.55.0",
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.0",
"debug": "^4.3.4"
},
"engines": {
@ -1700,13 +1700,13 @@
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.55.0.tgz",
"integrity": "sha512-OK+cIO1ZGhJYNCL//a3ROpsd83psf4dUJ4j7pdNVzd5DmIk+ffkuUIX2vcZQbEW/IR41DYsfJTB19tpCboxQuw==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.0.tgz",
"integrity": "sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/visitor-keys": "5.55.0"
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -1717,9 +1717,9 @@
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.55.0.tgz",
"integrity": "sha512-M4iRh4AG1ChrOL6Y+mETEKGeDnT7Sparn6fhZ5LtVJF1909D5O4uqK+C5NPbLmpfZ0XIIxCdwzKiijpZUOvOug==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.0.tgz",
"integrity": "sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -1730,13 +1730,13 @@
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.55.0.tgz",
"integrity": "sha512-I7X4A9ovA8gdpWMpr7b1BN9eEbvlEtWhQvpxp/yogt48fy9Lj3iE3ild/1H3jKBBIYj5YYJmS2+9ystVhC7eaQ==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz",
"integrity": "sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/visitor-keys": "5.55.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -1757,12 +1757,12 @@
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.55.0.tgz",
"integrity": "sha512-q2dlHHwWgirKh1D3acnuApXG+VNXpEY5/AwRxDVuEQpxWaB0jCDe0jFMVMALJ3ebSfuOVE8/rMS+9ZOYGg1GWw==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz",
"integrity": "sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/types": "5.57.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@ -3402,9 +3402,9 @@
}
},
"node_modules/eslint-plugin-github": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-4.6.1.tgz",
"integrity": "sha512-AjCxE+2JmT+ppq3AVNra3iJ0BTAj6rYmtHJtkEcIEtrBHVi9xmCl5ZdIYLh7U/YKGT2cttdcYvbe59HEYW67KA==",
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-4.7.0.tgz",
"integrity": "sha512-SIFSy6IXtN3aGQ6YyFWg/oxRUyAcYwg5G0wh+ov1HQCvmp+Pzs1GzeVjU8QcIQSSJfverQzuxWrJCAln/d2PuQ==",
"dev": true,
"dependencies": {
"@github/browserslist-config": "^1.0.0",
@ -6403,9 +6403,9 @@
}
},
"node_modules/prettier": {
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
"version": "2.8.7",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
@ -8985,9 +8985,9 @@
}
},
"@types/jest": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.1.tgz",
"integrity": "sha512-zDQSWXG+ZkEvs2zFFMszePhx4euKz+Yt3Gg1P+RHjfJBinTTr6L2DEyovO4V/WrKXuF0Dgn56GWGZPDa6TW9eQ==",
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.0.tgz",
"integrity": "sha512-3Emr5VOl/aoBwnWcH/EFQvlSAmjV+XtV9GGu5mwdYew5vhQh0IUZx/60x0TzHDu09Bi7HMx10t/namdJw5QIcg==",
"dev": true,
"requires": {
"expect": "^29.0.0",
@ -9018,9 +9018,9 @@
"dev": true
},
"@types/node": {
"version": "18.15.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.3.tgz",
"integrity": "sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==",
"version": "18.15.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.10.tgz",
"integrity": "sha512-9avDaQJczATcXgfmMAW3MIWArOO7A+m90vuCFLr8AotWf8igO/mRoYukrk2cqZVtv38tHs33retzHEilM7FpeQ==",
"dev": true
},
"@types/prettier": {
@ -9105,41 +9105,41 @@
}
},
"@typescript-eslint/parser": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.55.0.tgz",
"integrity": "sha512-ppvmeF7hvdhUUZWSd2EEWfzcFkjJzgNQzVST22nzg958CR+sphy8A6K7LXQZd6V75m1VKjp+J4g/PCEfSCmzhw==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.0.tgz",
"integrity": "sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.55.0",
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/typescript-estree": "5.55.0",
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.0",
"debug": "^4.3.4"
},
"dependencies": {
"@typescript-eslint/scope-manager": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.55.0.tgz",
"integrity": "sha512-OK+cIO1ZGhJYNCL//a3ROpsd83psf4dUJ4j7pdNVzd5DmIk+ffkuUIX2vcZQbEW/IR41DYsfJTB19tpCboxQuw==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.0.tgz",
"integrity": "sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/visitor-keys": "5.55.0"
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0"
}
},
"@typescript-eslint/types": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.55.0.tgz",
"integrity": "sha512-M4iRh4AG1ChrOL6Y+mETEKGeDnT7Sparn6fhZ5LtVJF1909D5O4uqK+C5NPbLmpfZ0XIIxCdwzKiijpZUOvOug==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.0.tgz",
"integrity": "sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.55.0.tgz",
"integrity": "sha512-I7X4A9ovA8gdpWMpr7b1BN9eEbvlEtWhQvpxp/yogt48fy9Lj3iE3ild/1H3jKBBIYj5YYJmS2+9ystVhC7eaQ==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz",
"integrity": "sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/visitor-keys": "5.55.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -9148,12 +9148,12 @@
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.55.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.55.0.tgz",
"integrity": "sha512-q2dlHHwWgirKh1D3acnuApXG+VNXpEY5/AwRxDVuEQpxWaB0jCDe0jFMVMALJ3ebSfuOVE8/rMS+9ZOYGg1GWw==",
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz",
"integrity": "sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.55.0",
"@typescript-eslint/types": "5.57.0",
"eslint-visitor-keys": "^3.3.0"
}
}
@ -10371,9 +10371,9 @@
}
},
"eslint-plugin-github": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-4.6.1.tgz",
"integrity": "sha512-AjCxE+2JmT+ppq3AVNra3iJ0BTAj6rYmtHJtkEcIEtrBHVi9xmCl5ZdIYLh7U/YKGT2cttdcYvbe59HEYW67KA==",
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-4.7.0.tgz",
"integrity": "sha512-SIFSy6IXtN3aGQ6YyFWg/oxRUyAcYwg5G0wh+ov1HQCvmp+Pzs1GzeVjU8QcIQSSJfverQzuxWrJCAln/d2PuQ==",
"dev": true,
"requires": {
"@github/browserslist-config": "^1.0.0",
@ -12580,9 +12580,9 @@
"dev": true
},
"prettier": {
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
"version": "2.8.7",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
"dev": true
},
"prettier-linter-helpers": {

View File

@ -38,20 +38,20 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/jest": "^29.4.1",
"@types/node": "^18.15.3",
"@typescript-eslint/parser": "^5.55.0",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.10",
"@typescript-eslint/parser": "^5.57.0",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.36.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-github": "^4.6.1",
"eslint-plugin-github": "^4.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"jest": "^29.5.0",
"jest-circus": "^29.4.2",
"jest-environment-jsdom": "^29.5.0",
"js-yaml": "^4.1.0",
"prettier": "^2.8.4",
"prettier": "^2.8.7",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
}

View File

@ -158,10 +158,10 @@ export class GitHubHelper {
requestReviewersParams['reviewers'] = inputs.reviewers
core.info(`Requesting reviewers '${inputs.reviewers}'`)
}
if (inputs.teamReviewers.length > 0) {
requestReviewersParams['team_reviewers'] = inputs.teamReviewers
core.info(`Requesting team reviewers '${inputs.teamReviewers}'`)
}
// if (inputs.teamReviewers.length > 0) {
// requestReviewersParams['team_reviewers'] = inputs.teamReviewers
// core.info(`Requesting team reviewers '${inputs.teamReviewers}'`)
// }
if (Object.keys(requestReviewersParams).length > 0) {
try {
await this.octokit.rest.pulls.requestReviewers({
@ -178,6 +178,147 @@ export class GitHubHelper {
}
}
const orgs = inputs.teamReviewers.map(team => {
if (!team.includes('/')) {
throw new Error(
`Team ${team} is not in the correct format. It should be in the format org/team`
)
}
return team.split('/')[0]
})
const distinctOrgs = [...new Set(orgs)]
core.debug(`distinctOrgs: ${distinctOrgs}`)
const orgTeams = await Promise.all(
distinctOrgs.map(org => this.getOrgTeams(org))
)
const teamIds = inputs.teamReviewers.map(team => {
const [org, teamName] = team.split('/')
const orgTeam = orgTeams.find(
orgTeam => orgTeam.organization.login === org
)
if (!orgTeam) {
throw new Error(`Org ${org} not found`)
}
const teamId = orgTeam.organization.teams.edges.find(
team => team.node.slug === teamName
)?.node.id
if (!teamId) {
throw new Error(`Team ${teamName} not found in ${org}`)
}
return teamId
})
core.debug(`teamIds: ${teamIds}`)
if (teamIds.length > 0) {
const repository = this.parseRepository(baseRepository)
const pullNodeId = await this.getPullNodeId(
repository.owner,
repository.repo,
pull.number
)
core.debug(`pullNodeId: ${pullNodeId}`)
await this.requestReviewers(pullNodeId, teamIds)
}
return pull
}
async getOrgTeams(orgName: string): Promise<OrgTeams> {
const query = `
query($orgName: String!, $teamCount: Int!) {
organization(login: $orgName) {
login
teams(first: $teamCount) {
edges {
node {
id
slug
}
}
}
}
}
`
const teamCount = 100
return this.octokit.graphql<OrgTeams>(query, {
orgName,
teamCount
})
}
async getPullNodeId(
owner: string,
repo: string,
pullNumber: number
): Promise<string> {
const query = `
query($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: ${pullNumber}) {
id
}
}
}
`
return (
await this.octokit.graphql<PullRequestResponse>(query, {
owner,
repo
})
).repository.pullRequest.id
}
async requestReviewers(
pullRequestId: string,
teamIds: string[]
): Promise<void> {
const mutation = `
mutation($input: RequestReviewsInput!) {
requestReviews(input: $input) {
clientMutationId
}
}
`
await this.octokit
.graphql(mutation, {
input: {
pullRequestId,
teamIds: teamIds,
union: true
}
})
.then(response => {
core.info('Reviews requested successfully')
})
.catch(error => {
core.error(error)
})
}
}
interface OrgTeams {
organization: {
login: string
teams: {
edges: {
node: {
id: string
slug: string
}
}[]
}
}
}
interface PullRequestResponse {
repository: {
pullRequest: {
id: string
}
}
}