Naga
Naga

Reputation: 393

How to disable Github branch protection rule for certain/auto-generated files

I have a git repository where some of the configuration files are auto-generated by scripts and pushed to the main branch. I like to enable branch protection rule to protect the main branch but like to disable these rules for certain file patterns.

Whether this is possible in Github?

Upvotes: 4

Views: 2576

Answers (2)

Rav Singh Sandhu
Rav Singh Sandhu

Reputation: 62

As others said this is not directly possible there are workarounds, use a workflow file to check when changes to these files are detected and automatically merge or push these changes if they pass certain checks

Upvotes: 0

VonC
VonC

Reputation: 1324188

While it is not possible, you could isolate those auto-generated script in their own folder.

And that folder could be a submodule (as illustrated here), referencing your own repository, but following a different branch, one which is not push-protected.

git submodule add -b scripts -- /url/to/your/own/repo scripts
git commit -m "Add script branch as submodule folder"

From the main branch, a git submodule update --remote would pull the latest of the scripts branch into the scripts subfolder.

Upvotes: 2

Related Questions