Skip to content

Commit e43a7a4

Browse files
authored
Add Reviewer Alias Validation to the Action (#7)
For private repositories that have access to the repository restricted, when a reviewer defined in the yaml configuration file does not have access to the repository, the current action will print out a message in the action that we failed to add that reviewer to the pull request. However, the action "succeeds" and only manually checking the logs lets the PR author know that something went wrong. The proposal in this change is to help PR authors detect when the aliases that are configured to be added to a PR do not have access. A comment gets created in the pull request with the aliases that do not have access. If the PR author solves this permission problem (either by giving access or removing the alias the config), the action will update the previous comment to notify the user that "All issues have been resolved". Only one comment is added by the action, and that comment will get updated based on the issue during that action run. An additional parameter (`validate_all`) for the action has been added to allow the above validation to be run on every alias in the yaml configuration. This can be useful for scenarios where the PR author is editing the yaml configuration, and the workflow might want to validate those new alias at PR time instead of waiting until that alias is attempted to use in a subsequent PR and it fails.
1 parent 099c361 commit e43a7a4

9 files changed

+1175
-79
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ jobs:
209209
# This defaults to false if not specified.
210210
# See https://github.com/necojackarc/auto-request-review/issues/76 for more details.
211211
use_local: true
212+
# Validates that all reviewers inside the config file (e.g. .github/reviewers.yml specified
213+
# above) have access to be added as reviewers to the repository running this yaml. This
214+
# can be used similar to native CODEOWNER errors reported by github:
215+
# https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-codeowners-errors
216+
#
217+
# This defaults to false if not specified.
218+
validate_all: true
212219
```
213220
214221
### (Optional) GitHub Personal Access Token
@@ -248,3 +255,30 @@ on:
248255
#### Dependabot compatibility
249256

250257
Note that with the [recent change to GitHub Actions that are created by Dependabot](https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/), the `pull_request` event will no longer give access to your secrets to this action. Instead you will need to use the `pull_request_target` event. If you do this make sure to read [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) to understand the risks involved.
258+
259+
## Reviewer Access and Private Repos
260+
261+
The reviewer aliases defined in the configurations must have been given access to the repo in order to
262+
be added as a code reviewer to the pull request.
263+
264+
If the action attempts to assign a reviewer that does not have access to the repo, a comment will be
265+
automatically addded to the pull request to notify the author that not everyone was assigned.
266+
```
267+
The following reviewers did not have access to be added as reviewers, please review their access:
268+
269+
Individual Alias
270+
- jamoor-test-twice
271+
272+
Team Alias
273+
- fake-team-super-stale
274+
275+
Comment added by Auto Reviewer Robot 🤖: <Base64 Unique ID>
276+
```
277+
278+
If the action is re-run post an administrator giving access to the aliases, or the aliases are removed
279+
from the config yaml file, the action will update the comment to notify that all issues have been resolved.
280+
281+
```
282+
All reviewer issues have been resolved!
283+
Comment added by Auto Reviewer Robot 🤖: <Base64 Unique ID>
284+
```

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ inputs:
1212
use_local:
1313
required: false
1414
default: 'false'
15+
validate_all:
16+
required: false
17+
default: 'false'
1518
runs:
1619
using: 'node20'
1720
main: 'dist/index.js'

dist/index.js

+169-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)