CODEOWNERS that matches directories but not files

Is there a syntax that will allow codeowners on the directories and sub directories but not on the files themselves. Basically once the folder exist and has been reviewed by a codeowner the CI system can take care of making sure there changes work.

Hi @weekendsuperhero - thanks for reaching out on the GitHub Support Community.

You can specify an owner for the contents of a folder within a codeowners file, for example:

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
/build/logs/ @doctocat


This means that the user @doctocat needs to approve any changes to any files within the folder build/logs and any subfolders. It’s not possible to specify just the folder, and not the contents - and I’m not entirely sure what the use case would be for that scenario.

Codeowners is specifically for governing who approves changes - whereas a CI system would still run tests in the background to provide checks that would enable a human to approve the change in the PR.

I hope that helps!

1 Like

I guess I was hoping to have code owners on new sub directory creation but not on new files in the sub directory.