auto-request-review icon indicating copy to clipboard operation
auto-request-review copied to clipboard

Unable to use github team

Open litepl opened this issue 2 years ago • 5 comments

Hello,

I just don't know what I'm doing wrong...

workflow

name: Add default reviewers
run-name: Add default reviewers
on:
  pull_request:
    types: [opened, ready_for_review, reopened]
jobs:
  add-default-reviewers:
    runs-on: self-hosted
    steps:
      - name: Auto Request Review
        uses: necojackarc/[email protected]
        with:
          token: ${{ secrets.PAT_FOR_AUTO_REQUEST_REVIEW }}
          config: .github/reviewers.yaml

reviewers.yaml

reviewers:
  defaults:
    - team:devops
options:
  ignore_draft: true

PAT_FOR_AUTO_REQUEST_REVIEW has full access to all repos

The funny thing is, when I remove devops team from collaborators the job succeed but no reviewers are added. When I'm adding it with admin role, the error is:

Error: HttpError: Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the HardRockDigital/lt-test repository.

litepl avatar Jun 27 '23 13:06 litepl

Were you able to figure this out? I'm seeing the same. I invited the team to the repo and tested both read, triage roles.

jbergstroem avatar Aug 25 '23 16:08 jbergstroem

Were you able to figure this out? I'm seeing the same. I invited the team to the repo and tested both read, triage roles.

Nope. I had to focus on other things but I'm going to go back to this topic soon;

litepl avatar Aug 28 '23 16:08 litepl

@litepl

The funny thing is, when I remove devops team from collaborators the job succeed but no reviewers are added. When I'm adding it with admin role, the error is:

Error: HttpError: Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the HardRockDigital/lt-test repository.

It may suggest that the action tries to request reviews but it fails. Do you have any more log or error messages when you tried it with the devops team in your collaborators?

By the way, were you able to request a review for that team manually?

necojackarc avatar Dec 27 '23 23:12 necojackarc

@necojackarc -- I am having this same issue

When the team has access to the repo I get

Error: HttpError: Validation Failed: "Could not resolve to a node with the global id of 'T_kwDOBzcd9M4Adqj8'."

When I remove the team access to the repo I get:

Error: HttpError: Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the mds-emu/release-eng-test repository.

chrockhill12 avatar May 22 '24 20:05 chrockhill12

just in case anyone else runs in to this, i think the issue (at least for me) was the secrets.GITHUB_TOKEN is only scoped to the repository, and isn't able to read teams/members from the organization. my workaround for this was to create a fine-grained personal access token, with the organization as the resource owner, and give the token permissions to read teams/members, read/write pull requests, etc. you can then make this token available as an organization secret, or per repository.

the downside (aside from managing this token), is that any assignment that isn't team based will show up on the PR as coming from the user who created the token, not the organization. it's not a big deal for me, but you could create a generic user in the organization who owns the token if you wanted.

jonpitch avatar Aug 09 '24 14:08 jonpitch