Branch protection policies on specific paths

Is there a way to configure a branch protection policy which is only checked if the commits in that branch include changes within a specific path?

For example, I have a repo with /backend and /frontend folders. I’d like to set it up PR build policies so that the Backend-CI build is triggered and checked for status only if my branch contains changes in /backend. Similarly the Frontend-CI build is only triggered and checked if there are changes in frontend.

Azure DevOps supports this which is pretty helpful for improving validation times.

Hi @gaziqbal,

Thanks for being here! Check out this post, it might help.


1 Like

I have a similar question and the referenced article doesn’t address it. If I’m using a “monorepo” style of development and I have multiple “things” in the repo that each should have separate CI builds (GitHub Actions), is there a way to use branch protection on a per-branch-and-folder basis?

I’m guessing there isn’t but it would be nice to be able to say that branch master folder projectA is protected by status check buildProjectA and branch master folder projectB is protected by status check buildProjectB.


Completely agree with you @ardalis.
We’ve just gone through and built an entire CI pipeline for a monorepo, only to find out that we can’t configure GitHub with any meaningful branch protection.

I believe the monorepo pattern is becoming more and more popular, especially as the rise of the BFF + SPA pattern takes off. Being able to set protection on not just specific branches, but paths inside those branches - would be amazing, and very much needed going forward.

Would you know of any plans for implementing this @andreagriffiths11? Alternatively might you know where I can raise a feature request?

Our quick and messy alternative would be to have 1 pre-prod branch for our SPA, and another for the BFF. Then we configure our CI pipeline to automatically merge any changes on those branches back into master.