Exclude codeowners from dependabot PR
Asked Answered
H

1

6

We use a codeowners file to automatically assign reviews to Pull Requests. We also have Dependabot creating PRs for major versions.

We do not want to automatically add reviews to the PRs created by Dependabot. According to https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax it is not possible to use ! to exclude.

Is there a way to:

  • Use codeowners for all PRs created but users
  • Not assign reviewers on PRs create by Dependabot

Thanks!

I have read the documentation for Codeowners file, and for Dependabot. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/customizing-dependency-updates#setting-reviewers-and-assignees

We do not use any reviews in the Dependabot action.

Hydrometer answered 22/2, 2023 at 10:48 Comment(2)
Hey, good question! We are facing the same issue. Did you find a way? – Beetle
We got it to work, but I'm sure there would be a better solution for this πŸ˜… We just added package.json and package-lock.json to .github/CODEOWNERS This makes it work, but if a PR only affects the package files, no code owner will be added πŸ€” If you, or someone else, find a better way, please share it with me 😊 – Hydrometer
G
1

Using @andreas-olsson's comment, this is what I set up in the CODEOWNERS file.

This is slightly imperfect, as it means that if a real user only makes a change to a package.json file and no other files, the codeowners will not get notified of that PR. However, there is currently no better solution.

# All files are by default owned by this team,
# unless a more specific ownership rule is set below.
* @my-dev-team-name

# Don't automatically assign reviewers on PRs that only modify these files.
# As they have no owner listed, these files are not owned by anyone.
package.json
package-lock.json

Check out the CODEOWNERS syntax docs if you need help modifying this to fit your file structure (the above solution assumes that the package files are in the root directory).

Grodin answered 26/7, 2023 at 20:0 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.