0

I am writing a GitHub workflow where I am building documentation from the main branch docstrings and pushing it to gh-pages and having GitHub pages deploy off of gh-pages branch. How can I protect that branch so that only GitHub branches can push to it and not allow anyone else?

AugustusCaesar
  • 175
  • 2
  • 14
  • Can you just lock the branch and then only admins can force push? Im not sure you could protect it from yourself but if its locked then it becomes "read only" for everyone except admins. – ajgrinds May 16 '23 at 21:07
  • as long as someone random is not pushing to my gh-pages then I would be happy – AugustusCaesar May 16 '23 at 21:28

1 Answers1

0

A new branch protection rule can be set up at https://github.com/USERNAME/REPO/settings/branch_protection_rules/new. Any branch that has a matching name will be protected. The option "lock branch" will lock the branch and only allow admins to override and commit. Additionally, branch protection rules should be set up on main to require a pull request that way people cannot just push directly to main.

ajgrinds
  • 186
  • 11