Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to allow push from server to repo on protected branch? #8472

Closed
2 of 7 tasks
thestepafter opened this issue Oct 11, 2019 · 2 comments · Fixed by #8483
Closed
2 of 7 tasks

How to allow push from server to repo on protected branch? #8472

thestepafter opened this issue Oct 11, 2019 · 2 comments · Fixed by #8483
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@thestepafter
Copy link

  • Gitea version (or commit ref):
  • Git version: 2.17.1
  • Operating system: Ubuntu 18.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

So I am using a deployment service (Laravel Forge) and I want to automatically push production updates back to a protected branch before I deploy new updates. I am encountering this issue though and I'm not sure what the recommended approach would be. I had this working fine in Gitlab with a protect branch and the same SSH deploy key. (write access is enabled in Gitea for this branch.)

remote: Gitea: protected branch master can not be pushed to

What is the recommend approach with Gitea for pushing updates from production back to the repo on a protected brach?

@zeripath
Copy link
Contributor

You could add a whitelist.

Deploy keys act as the repository owner so if you add the repository owner to the whitelist that should work.

(Now, that might be difficult with an organisation but let me think)

We could add another option to the protection to allow writing deploy keys to push.

@thestepafter
Copy link
Author

thestepafter commented Oct 12, 2019

I solved this by adding my individual key (as organization and repository owner) to the server and setting .ssh/config to use that key when pushing back to the Gitea server.

The additional option sounds like a great idea though @zeripath. This would enable more fine grained control.

@zeripath zeripath added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Oct 13, 2019
zeripath added a commit that referenced this issue Oct 21, 2019
Add an option to protected branches to add writing deploy keys to the whitelist for pushing.

Please note this is technically a breaking change: previously if the owner of a repository was on the whitelist then any writing deploy key was effectively on the whitelist. This option will now need to be set if that is desired.

Closes #8472 

Details:
* Allow Protected Branches to Whitelist Deploy Keys
* Add migration
* Ensure that IsDeployKey is set to false on the http pushes
* add not null default false
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants