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?
True: when you have layered code owners, with a default or catch-all team (like an ops team) that has code owner rights over the entire repository but is only supposed to review occasionally, it becomes a bit trickier.
The key challenge is to make sure the ops team does not get spammed with review requests, even if they are the catch-all codeowners, unless their review is actually needed.
You can start with fine-tuning your CODEOWNERS file.
Make sure to organize your
.github/CODEOWNERS
file such that specific paths and folders have their respective code owners, while the ops team is the fallback for general oversight or unassigned paths:You will then still utilize GitHub Actions, but you will be a bit more specific this time. You will need an action that checks the files changed in the PR.
But:
For instance:
See also discussions/25797 for an illustration around
${{ github.event.before }}
and${{ github.event.after }}
.