GitHub Action to add reviewers to pull requests

I’m trying to create an action that will add reviewers to PRs, but I’m not sure this is possible based on the guidance here:

    https://developer.github.com/actions/managing-workflows/workflow-configuration-options/#pull-request-events-for-forked-repositories

For context, in Spack, there are ~3000 package recipes, and some of them have a maintainers field.  I want the action to query the maintainers for any modified package recipes, and add them as reviewers.

I’m not seeing how I can actually make this happen with the restrictions on actions for forked repositories.  The token in $GITHUB_TOKEN will only have permissions of the user who created the PR, and they won’t be able to do anything to my repo, right?  Is there something I’m missing?

If this isn’t possible, will it be possible one day?  It’d be nice to grant actions permissions to do things like this.

See the docs for the full rundown on the rights of the GITHUB_TOKEN secret. But no, the GITHUB_TOKEN is not associated with the person who created the PR. The GITHUB_TOKEN is associated with the repository in which the Action is run. Given that, it should be able to assign reviewers, so long as the Action knows the exact GitHub username of those reviewers ahead of time. The GITHUB_TOKEN can’t see into teams of an organization, for example.

I hope that helps!

1 Like