How to enforce review from codeowners without automatically requesting a review?
Asked Answered
Q

1

17

I have a GitHub repo which automatically requests reviews from the codeowners team (defined in .github/CODEOWNERS) when a pull request is first opened. What I want is to enforce the requirement that pull requests must be approved by a codeowner, but to stop sending these review requests when the pull request is first opened. i.e. the desired flow for a contributer is something like this:

open a pull request -> mess around, make changes -> manually request a review when ready (can't merge without codeowner approval)

This could be solved by getting contributers to open draft pull requests and only marking them as ready when they are actually ready, but contributers don't seem to want to do this. Contributers will usually open a (non-draft) pull request when it's not actually ready for review (force of habit I suppose).

Is there a way to do this, which doesn't rely on contributers using draft pull requests?

Quinquereme answered 7/6, 2022 at 16:2 Comment(3)
Thanks for asking, I'm wondering the same thing. If this can't be done, at the very least it would be great to not have the "automatically requested reviewers" be subscribed to the review automatically because it can lead to unwanted spam.Othilia
I've created a related discussion in github to see if it's something they would entertain or others would chime in on: github.com/orgs/community/discussions/35673#discussion-4459776Othilia
Thanks @Othilia - I've upvoted on the github thread.Quinquereme
W
1

I found other threads on GitHub forums people asking for the same thing. I think for the moment there is no setting in GitHub where you can do this. I found this comment: "For customized workflows like this, you may want to check out Probot. The Work in Progress Probot app gives an example of how to create a bot that can block the merging of PRs based on custom logic."

I see that you can do something like this with this app

version: 2
mergeable:
  - when: pull_request.*, pull_request_review.*
    name: 'Approval check'
    validate:
      - do: approvals
        min:
          count: 1
        limit:
          users: [ 'approverA', 'approverB' ]

It might solve your problem, but for my case where there are different codeowners for different parts of the application is not good enough.

Wellesley answered 23/3, 2023 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.