I have a GitHub repository with two folders, A and B. The first Folder A needs to require a Pull Requests to commit a change to the code so that I can implement a peer review process. Folder B I would like to be open, where users can commit changes freely, without requiring a Pull Request. Is this something that is possible? Any suggestions of how I could implement this?
CodePudding user response:
No this isn't possible. A pull-request policy is set at the branch level and there is no exclusion option for specific folders. You can use the CODE OWNERS feature to assign required reviewers to the parts that require review and then let people complete their own pull requests if no required reviewers are assigned.
See:
- https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
- https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches#require-pull-request-reviews-before-merging
An other option would be to have people commit changes to FolderB on a separate branch without protection and let GitHub actions merge the changes into target branch while bypassing protections. You'll need to use a Personal Access Token of a repository administrator to bypass the protections.