[BUG] - Github Action cannot assign teams

Hello there;

I have a little issue with github actions. Using curl and the default “GITHUB_TOKEN” from the github action; I can successfully add a user as a reviewer or refer to a user in a comment (with the @notation). But when it comes to teams, this doesnt work, it’s seems to be due to an authorization issue.

I don’t want to use a PAT as it’s not generic enough. Would you know a way to work around this or grant authorization to the github-action bot to have access to teams?

Regards

Antoine Dussarps

PS: The issue is also referenced here: https://github.com/peter-evans/create-pull-request/issues/155

What makes you think this is a bug? Is it documented somewhere that it should work?

@adussarps ,

This is not a bug.

When using the GitHub REST API “Request reviewers for a pull request” to add the team reviewers, the following preparations are required:

  1. The teams has been added into the repository as the collaborators.
  2. The authorization token of the API requires the “repo” scope.
    PAT_scope

The GITHUB_TOKEN does not have the “repo” scope, so you need to create a personal access token (PAT) with the “repo” scope at least.

Here is an example as reference:

Well, as it does work for standalone users and not for teams, I assumed it was not an intended behavior; but it might be just expected.

My point is, that it does work well with a “PAT” but it’s not a good and maintainable solution; as the token could get revoked or I might delete my account.

Would you know another way to work around this?

@adussarps ,

As mentioned above, accessing teams needs more permission scopes (“repo”) than accessing users. The GITHUB_TOKEN does not have the “repo” scope.

The GITHUB_TOKEN is automatically created by GitHub when before each job begins in the workflow. Is contains the “read/write” access for many permissions, and we can’t customize the permission scopes of this token.
Any users (include the external users) who can trigger workflows in your repository, they can use the GITHUB_TOKEN to do any thing ( read/write ) allowed by the permissions of the token in the workflow.
In the workflow triggered from the forked repository, the GITHUB_TOKEN only has the “read” access for the allowed permissions.
If extending the permission scopes of GITHUB_TOKEN, this may bring some security risk.

When you create a personal access token (PAT), you can customize and limit the permission scopes of the token so that other users can’t use this PAT to do some things you don’t want them to do in the workflow.