Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/class/prsReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ export default class PullRequestReview {
* @returns {Promise<void>}
*/
public async botPRs(): Promise<void> {
const maintainers: ReadonlyArray<string> = await this.context.octokit.pulls.listReviews({
owner: this.context.payload.repository.owner.login,
repo: this.context.payload.repository.name,
pull_number: this.context.payload.pull_request.number
}).then((response) => {
return response.data.filter((data) =>
data.user?.login &&
this.context.payload.review.user.login !== data.user.login &&
data.user.type.toLowerCase() !== "bot" &&
["COLLABORATOR", "MEMBER", "OWNER"].includes(data.author_association)
).map((data) => {
return `@${data.user?.login}`;
});
});
if (this.context.payload.sender.login === this.context.payload.repository.owner.login) {
// Owner
if (this.context.payload.review.state === "approved") {
Expand All @@ -137,7 +151,7 @@ export default class PullRequestReview {
await this.createReview(reviewMessage, ["Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} your pull request has requested changes by \`[OWNER]\`@${this.context.payload.review.user.login}. Please address their comments before I'm merging this PR, thanks!`;
const reviewMessage = `@${this.context.payload.pull_request.user.login} pull request has requested changes by \`[OWNER]\`@${this.context.payload.review.user.login}. ${maintainers.join(", ")} please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name === "Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Approved", "Pending"]);
} else {
Expand All @@ -153,7 +167,7 @@ export default class PullRequestReview {
await this.createReview(reviewMessage, ["Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by \`[MAINTAINER]\`@${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I"m merging this PR, thanks!`;
const reviewMessage = `Pull request has requested changes by \`[MAINTAINER]\`@${this.context.payload.review.user.login}. ${maintainers.join(", ")} please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name === "Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Approved", "Pending"]);
} else {
Expand All @@ -170,7 +184,7 @@ export default class PullRequestReview {
await this.createReview(reviewMessage, ["Others Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by @${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I'm merging this PR, thanks!`;
const reviewMessage = `Pull request has requested changes by @${this.context.payload.review.user.login}. ${maintainers.join(", ")} please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name === "Others Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Others Approved", "Pending"]);
} else {
Expand Down