ci: request subsystem maintainers review (#1053)

Link: https://github.com/nix-community/stylix/pull/1053

Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: Daniel Thwaites <danth@danth.me>
Reviewed-by: Matt Sturgeon <matt@sturgeon.me.uk>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
awwpotato 2025-07-30 07:12:40 -07:00 committed by GitHub
parent 4bfd32c8f9
commit b4e1daad3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 101 additions and 1 deletions

81
.github/workflows/request-reviewers.yml vendored Normal file
View file

@ -0,0 +1,81 @@
---
name: Request Reviewers
on:
pull_request_target:
types: [opened, ready_for_review, reopened, synchronize]
paths:
- 'modules/'
jobs:
request-reviewers:
runs-on: ubuntu-24.04
if: vars.APP_ID
steps:
- uses: actions/checkout@v4.2.2
with:
ref: ${{ github.base_ref }}
- uses: cachix/install-nix-action@v31
- uses: cachix/cachix-action@v16
with:
name: nix-community
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
continue-on-error: true
- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: read
permission-pull-requests: write
- run: nix build .#subsystem-maintainers
- id: get-reviewers
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAX_REVIEWERS: 5
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
printf \
'reviewers=%s\n' \
"$(
gh pr diff --name-only "$PR_NUMBER" |
jq \
--argjson max_reviewers "$MAX_REVIEWERS" \
--raw-input \
--raw-output \
--slurp \
--slurpfile maintainers result '
($maintainers[0] | keys_unsorted) as $subsystems |
split("\n") as $changed_files |
[
$changed_files[] as $changed_file |
(
$maintainers[0][
$subsystems[] |
select(
. as $subsystem |
$changed_file |
startswith($subsystem)
)
]
)[]
] |
unique |
if length <= $max_reviewers then
. | join(",")
else
""
end
'
)" \
>>"$GITHUB_OUTPUT"
- uses: AveryCameronUofR/add-reviewer-gh-action@1.0.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
reviewers: ${{ steps.get-reviewers.outputs.reviewers }}