We have github enterprise set up at work and I want a travis build to push code back to the repo as part of the master branch build. It basically updates the changelog, commits the file and need to push back to the repo. The problem is that we have protected branches, and trying to push with the deploy key set up with travis yields:
remote: error: Required status check "continuous-integration/travis-ci" is expected.
At least one approved review is required.
! [remote rejected] master -> master (protected branch hook declined)
It doesn't help that the protected branch is set up to allow admins to override, becuase the deploy key is not regarded as an admin AFAIU.
By default, GitHub blocks force pushes on all protected branches. When you enable force pushes to a protected branch, you can choose one of two groups who can force push: Allow everyone with at least write permissions to the repository to force push to the branch, including those with admin permissions.
In the upper-right corner of any GitHub page, click your profile photo, then click Your profile. On your profile page, click Repositories, then click the name of your repository. From your repository, click Settings. In the sidebar, click Deploy Keys, then click Add deploy key.
Interactive rebase and reword are disabled for pushed commits of protected branches, however, it is possible to do a regular rebase.
Now in 2021 the documentation says that "[d]eploy keys with write access can perform the same actions as an organization member with admin access". If you disable the Include administrators restriction, the deploy key can be used to push to the protected branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With