mirror of
https://github.com/neovim/neovim.git
synced 2026-07-29 11:58:02 +00:00
Problem:
- The `reviewers_add`/`reviewers_remove` CI jobs checkout the repo only
for the purpose of `require('…/reviewers_add.js')`.
- `reviewers_remove` also runs on `closed`, so a merged fork PR will trip
the new allow-unsafe-pr-checkout guard of `actions/checkout@v7`.
Solution:
- Drop the use of `actions/checkout`.
- Inline the script in the CI yaml definitions.
- Also await the mutating calls (previously fire-and-forget) and guard
empty reviewer lists.
74 lines
2.5 KiB
YAML
74 lines
2.5 KiB
YAML
name: "reviewers: add"
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled, ready_for_review, reopened]
|
|
workflow_call:
|
|
|
|
permissions: {}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
request-reviewer:
|
|
if: github.event.pull_request.state == 'open' && github.event.pull_request.draft == false && !endsWith(github.actor, '[bot]')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pull-requests: write
|
|
steps:
|
|
- name: 'Request reviewers'
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const labelReviewers = {
|
|
build: ["dundargoc", "jamessan", "justinmk"],
|
|
ci: ["dundargoc", "jamessan", "justinmk"],
|
|
column: ["lewis6991"],
|
|
comment: ["echasnovski"],
|
|
defaults: ["gpanders"],
|
|
diagnostic: ["gpanders"],
|
|
diff: ["lewis6991"],
|
|
editorconfig: ["gpanders"],
|
|
marks: ["bfredl"],
|
|
filetype: ["clason"],
|
|
inccommand: ["famiu"],
|
|
lsp: ["MariaSolOs", "ribru17"],
|
|
netrw: ["justinmk"],
|
|
options: ["famiu"],
|
|
"platform:nix": ["teto"],
|
|
"project-management": ["bfredl", "justinmk"],
|
|
snippet: ["MariaSolOs"],
|
|
statusline: ["famiu"],
|
|
treesitter: ["bfredl", "clason", "lewis6991", "wookayin", "ribru17"],
|
|
tui: ["gpanders"],
|
|
typo: ["dundargoc"],
|
|
"vim-patch": ["zeertzjq"],
|
|
};
|
|
|
|
// Fetch labels live: when called from labeler_pr.yml this job runs
|
|
// after labels are applied, so the event payload is stale.
|
|
const { data: pr } = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.issue.number,
|
|
});
|
|
|
|
const reviewers = new Set();
|
|
for (const label of pr.labels.map((e) => e.name)) {
|
|
for (const r of labelReviewers[label] || []) {
|
|
reviewers.add(r);
|
|
}
|
|
}
|
|
// Can't review your own PR.
|
|
reviewers.delete(pr.user.login);
|
|
|
|
if (reviewers.size) {
|
|
await github.rest.pulls.requestReviewers({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.issue.number,
|
|
reviewers: Array.from(reviewers),
|
|
});
|
|
}
|