mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
ci: add reviewers if labels are manually added after PR creation
This commit is contained in:
parent
3b4bf88710
commit
b0bcbb08a9
90
.github/workflows/labeler.yml
vendored
90
.github/workflows/labeler.yml
vendored
@ -32,93 +32,3 @@ jobs:
|
||||
- name: "Extract commit scope and add as label"
|
||||
continue-on-error: true
|
||||
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')"
|
||||
|
||||
add-reviewer:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ["triage", "type-scope"]
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/github-script@v5
|
||||
with:
|
||||
script: |
|
||||
const reviewers = []
|
||||
|
||||
const { data: { labels } } = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number
|
||||
})
|
||||
const label_names = labels.map(label => label.name)
|
||||
|
||||
if (label_names.includes('api')) {
|
||||
reviewers.push("bfredl")
|
||||
reviewers.push("gpanders")
|
||||
reviewers.push("muniter")
|
||||
}
|
||||
|
||||
if (label_names.includes('ci')) {
|
||||
reviewers.push("jamessan")
|
||||
}
|
||||
|
||||
if (label_names.includes('diagnostic')) {
|
||||
reviewers.push("gpanders")
|
||||
}
|
||||
|
||||
if (label_names.includes('distribution')) {
|
||||
reviewers.push("jamessan")
|
||||
}
|
||||
|
||||
if (label_names.includes('documentation')) {
|
||||
reviewers.push("clason")
|
||||
}
|
||||
|
||||
if (label_names.includes('extmarks')) {
|
||||
reviewers.push("bfredl")
|
||||
}
|
||||
|
||||
if (label_names.includes('filetype')) {
|
||||
reviewers.push("clason")
|
||||
reviewers.push("gpanders")
|
||||
}
|
||||
|
||||
if (label_names.includes('gui')) {
|
||||
reviewers.push("glacambre")
|
||||
reviewers.push("smolck")
|
||||
}
|
||||
|
||||
if (label_names.includes('lsp')) {
|
||||
reviewers.push("mfussenegger")
|
||||
reviewers.push("mjlbach")
|
||||
}
|
||||
|
||||
if (label_names.includes('treesitter')) {
|
||||
reviewers.push("bfredl")
|
||||
reviewers.push("vigoux")
|
||||
}
|
||||
|
||||
if (label_names.includes('typo')) {
|
||||
reviewers.push("dundargoc")
|
||||
}
|
||||
|
||||
if (label_names.includes('ui')) {
|
||||
reviewers.push("bfredl")
|
||||
}
|
||||
|
||||
if (label_names.includes('vim-patch')) {
|
||||
reviewers.push("janlazo")
|
||||
reviewers.push("seandewar")
|
||||
reviewers.push("zeertzjq")
|
||||
}
|
||||
|
||||
const index = reviewers.indexOf(context.actor);
|
||||
if (index > -1) {
|
||||
reviewers.splice(index, 1);
|
||||
}
|
||||
|
||||
github.rest.pulls.requestReviewers({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
reviewers: reviewers
|
||||
});
|
||||
|
99
.github/workflows/reviews.yml
vendored
Normal file
99
.github/workflows/reviews.yml
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
name: "Request reviews"
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
workflow_run:
|
||||
workflows: [Pull Request Labeler]
|
||||
types: [completed]
|
||||
jobs:
|
||||
request-reviewer:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/github-script@v5
|
||||
with:
|
||||
script: |
|
||||
// The number of the pull request that triggered this run. If label
|
||||
// was added manually by a person the number will be stored in current
|
||||
// context, otherwise the number will be stored in the payload.
|
||||
const pr_number = context.issue.number || context.payload.workflow_run.pull_requests[0].number
|
||||
|
||||
const pr_data = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: pr_number
|
||||
})
|
||||
const labels = pr_data.data.labels.map(e => e.name)
|
||||
|
||||
const reviewers = new Set()
|
||||
if (labels.includes('api')) {
|
||||
reviewers.add("bfredl")
|
||||
reviewers.add("gpanders")
|
||||
reviewers.add("muniter")
|
||||
}
|
||||
|
||||
if (labels.includes('ci')) {
|
||||
reviewers.add("jamessan")
|
||||
}
|
||||
|
||||
if (labels.includes('diagnostic')) {
|
||||
reviewers.add("gpanders")
|
||||
}
|
||||
|
||||
if (labels.includes('distribution')) {
|
||||
reviewers.add("jamessan")
|
||||
}
|
||||
|
||||
if (labels.includes('documentation')) {
|
||||
reviewers.add("clason")
|
||||
}
|
||||
|
||||
if (labels.includes('extmarks')) {
|
||||
reviewers.add("bfredl")
|
||||
}
|
||||
|
||||
if (labels.includes('filetype')) {
|
||||
reviewers.add("clason")
|
||||
reviewers.add("gpanders")
|
||||
}
|
||||
|
||||
if (labels.includes('gui')) {
|
||||
reviewers.add("glacambre")
|
||||
reviewers.add("smolck")
|
||||
}
|
||||
|
||||
if (labels.includes('lsp')) {
|
||||
reviewers.add("mfussenegger")
|
||||
reviewers.add("mjlbach")
|
||||
}
|
||||
|
||||
if (labels.includes('treesitter')) {
|
||||
reviewers.add("bfredl")
|
||||
reviewers.add("vigoux")
|
||||
}
|
||||
|
||||
if (labels.includes('typo')) {
|
||||
reviewers.add("dundargoc")
|
||||
}
|
||||
|
||||
if (labels.includes('ui')) {
|
||||
reviewers.add("bfredl")
|
||||
}
|
||||
|
||||
if (labels.includes('vim-patch')) {
|
||||
reviewers.add("janlazo")
|
||||
reviewers.add("seandewar")
|
||||
reviewers.add("zeertzjq")
|
||||
}
|
||||
|
||||
// Remove person that opened the PR since they can't review themselves
|
||||
const pr_opener = pr_data.data.user.login
|
||||
reviewers.delete(pr_opener)
|
||||
|
||||
github.rest.pulls.requestReviewers({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: pr_number,
|
||||
reviewers: Array.from(reviewers)
|
||||
});
|
Loading…
Reference in New Issue
Block a user