Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue Assigning GitHub Team as Reviewer within Enterprise -- Works with auto-assigning groups, and individuals #121

Open
chrockhill12 opened this issue May 21, 2024 Discussed in #120 · 1 comment

Comments

@chrockhill12
Copy link

Discussed in #120

Originally posted by chrockhill12 May 17, 2024
Config file:

reviewers:
  # The default reviewers
  defaults: # currently defaults to the default reviewers.  Will randomly assign one of them (or 2 depending on "number of reviewers" config)
      - team:mds-platform
      - crockhill_sfemu

  groups:
  #MDS-Platforms  
      mds-plaform-approver:
        - crockhill_sfemu

  per_author:
  # MDS Platforms Review Assignments
      mds-plaform-approver:
        - team:mds-platform


  options:
    ignore_draft: true
    ignored_keywords:
      - DO NOT REVIEW
    enable_group_assignment: true

    # Randomly pick reviewers up to this number.
    # Do not set this option if you'd like to assign all matching reviewers.
    number_of_reviewers: 1
    #update

    # If it's true, the last matching files-change pattern takes the most precedence (CODEOWNERS-compatible)
  
    # last_files_match_only: false

Error with team having proper access to the repo:

Run mds-emu/[email protected]
Fetching configuration file from the source branch
Fetching changed files in the pull request
Identifying reviewers based on the changed files
A "files" key does not exist in config; returning no reviewers for changed files.
Identifying reviewers based on the author
Adding other group members to reviewers if group assignment feature is on
Group assignment feature is disabled
Randomly picking reviewers if the number of reviewers is set
Requesting review to team:mds-platform
Error: HttpError: Validation Failed: "Could not resolve to a node with the global id of 'T_kwDOBzcd9M4Adqj[8](https://github.com/mds-emu/CR-Test-Repo/actions/runs/9117703018/job/25113345970#step:2:9)'."

Error when I remove the team from access the repo:

Error: HttpError: Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the mds-emu/CR-Test-Repo repository.
```</div>
@felix-bose
Copy link

It also took me quite a few runs to figure out a setup that works.
I did the following:

  • Create a PAT (personal access token) scoped to the repo with the following permissions:
    • Members: read and write, Team discussions: read and write, Metadata: read-only, Pull Requests: read and write
  • make sure your team name is correct
  • modify your action checkout the repo and use a local config as the token has no access writes otherwise (might also be controllable via another permission, but didn't dare to try)
    Here is what my action ended up looking:
on:
  pull_request_target:
    types: [opened, ready_for_review, reopened]

jobs:
  assign-reviewer:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - name: Auto request review
          uses: necojackarc/[email protected]
          with:
            token: ${{ secrets.TOKEN_TEAM_ASSIGNMENT }}
            config: .github/reviewers.yml
            use_local: true

Hope that helps!
Plus for testing make sure you add pull_request as a trigger for your action otherwise the changes to your yml might not get picked up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants