Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add issue auto-assignment and improve PR reviewer assignment #3045

Merged
merged 4 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
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
12 changes: 0 additions & 12 deletions .github/pr-auto-assign-config.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/issue-auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Auto assign maintainer to issue'
on:
issues:
types: [opened]

permissions:
issues: write

jobs:
assign-user:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const assignees = ['mstoykov', 'imiric', 'codebien', 'olegbespalov', 'oleiade'];
const assigneeCount = 1;

// Do not automatically assign users if someone was already assigned or it was opened by a maintainer
if (context.payload.issue.assignees.length > 0 || assignees.contains(context.payload.issue.user.login)) {
return;
}

github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: assignees.sort(() => 0.5 - Math.random()).slice(0, assigneeCount),
mstoykov marked this conversation as resolved.
Show resolved Hide resolved
});
19 changes: 16 additions & 3 deletions .github/workflows/pr-auto-assign.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
name: 'Auto Assign'
name: 'Auto assign PR reviewers'
on:
pull_request_target:
types: [opened, ready_for_review, reopened]

permissions:
pull-requests: write

jobs:
add-reviews:
if: ${{ join(github.event.pull_request.requested_reviewers.*.login, ',') == '' }}
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/auto-assign-action@6d966a1f3bd73adfe44dd19dc42cc5845e39ebd3 # v1.2.4
- uses: actions/github-script@v6
Comment on lines -11 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this is a relatively trivial dependency to remove 👍

with:
configuration-path: ".github/pr-auto-assign-config.yml"
script: |
const reviewers = ['mstoykov', 'imiric', 'codebien', 'olegbespalov', 'oleiade'];
const reviewerCount = 2;

const reviewersWithoutAuthor = reviewers.filter(user => user !== context.payload.pull_request.user.login);
github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
reviewers: reviewersWithoutAuthor.sort(() => 0.5 - Math.random()).slice(0, reviewerCount),
});