Link: https://github.com/nix-community/stylix/pull/2000 Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: 0xda157 <da157@voidq.com>
89 lines
2.6 KiB
YAML
89 lines
2.6 KiB
YAML
---
|
|
name: Request Reviewers
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, ready_for_review, reopened, synchronize]
|
|
paths:
|
|
- 'modules/**'
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
request-reviewers:
|
|
runs-on: ubuntu-24.04
|
|
if: vars.APP_ID
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
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-members: read
|
|
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_AUTHOR: ${{ github.event.pull_request.user.login }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
printf \
|
|
'reviewers=%s\n' \
|
|
"$(
|
|
gh pr diff --name-only "$PR_NUMBER" |
|
|
jq \
|
|
--arg pr_author "$PR_AUTHOR" \
|
|
--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 |
|
|
map(select(. != $pr_author)) |
|
|
if length <= $max_reviewers then
|
|
. | join(",")
|
|
else
|
|
""
|
|
end
|
|
'
|
|
)" \
|
|
>>"$GITHUB_OUTPUT"
|
|
|
|
- uses: AveryCameronUofR/add-reviewer-gh-action@1.0.4
|
|
with:
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
reviewers: ${{ steps.get-reviewers.outputs.reviewers }}
|