Replies: 89 comments 84 replies
-
Also mentioned and requested here: https://github.community/t/allowing-github-actions-bot-to-push-to-protected-branch/16536 |
Beta Was this translation helpful? Give feedback.
-
Even though it wouldn't work in all use cases for all people, treating the E.g. at my company the |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Just encountered this exact issue. This is certainly great to have for smaller hobby teams as well where you don't really want nor need to setup whole delivery pipelines. |
Beta Was this translation helpful? Give feedback.
-
Yes, GitHub, let's get this feature in please. |
Beta Was this translation helpful? Give feedback.
-
Would also like this implemented. 👍 |
Beta Was this translation helpful? Give feedback.
-
That would be a great GA to implement! |
Beta Was this translation helpful? Give feedback.
-
+1 I had to implement a walkaround to cater for such requirements which I do not encourage following... Update: If you're very keen, you can see multiple ideas/solutions posted across the board linking to this issue. |
Beta Was this translation helpful? Give feedback.
-
does this fit your need ? https://github.blog/changelog/2022-08-18-bypass-branch-protections-with-a-new-permission/ |
Beta Was this translation helpful? Give feedback.
-
Also interested in a solution - I'm trying to auto bump the version but the branch protection rule I have on |
Beta Was this translation helpful? Give feedback.
-
Also looking for a solution! I have a python-black formatter that pushes code to the main branch but the protection rules won't allow it |
Beta Was this translation helpful? Give feedback.
-
I'm running into this issue as well. I use |
Beta Was this translation helpful? Give feedback.
-
Can we bypass the permission rules with Gitbook? We are facing the same issue but within the same company (!) |
Beta Was this translation helpful? Give feedback.
-
As a simplification of the "service user" approach outlined by the OP: for the commit(s) pushed by the "service user", one can consider using |
Beta Was this translation helpful? Give feedback.
-
Github, this is a need for full automation after deploys. PLEASE consider this soon. |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
I agree this would solve a real gap. Today the only workaround is creating a service account with a PAT and wiring it into workflows, which is both insecure and hard to scale. A native option under branch protection (like "allow GitHub Actions from this branch to push back" ) would reduce risk and simplify setups. Right now branch protection and automation are working against each other instead of together. |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 (also i love you GitHub people. stay beautiful <3) |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
Your critique of the common workarounds is fair: PATs and bot users are clunky; letting raw GITHUB_TOKEN bypass would be dangerous.The checkbox idea is good in spirit-it expresses the least-privilege intent you want-but it would need a few guardrails (see below), otherwise it recreates the very risks branch protection exists to mitigate. First, I can think of some issues with the raw idea:
If GitHub would be designing such checkbox, I'd insist on all of these guardrails:
So, I can see why this isn't Github priority ATM. But I'd vouch for it. |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There are workflows in which it is desirable to have the workflow itself make changes (such as updating a
pom.xml
,packages.json
,CHANGELOG.md
, etc.) on a branch which is otherwise protected from direct changes.Some things that don't work (or don't work well):
GITHUB_TOKEN
to the "Restrict who can push to matching branches" list, but even if it were this wouldn't be a useful solution, because then any action from any branch could bypass the branch protection rules, making them too easily circumventable.push
events to make sure that they ignore any commits pushed by the service user (the way they'd ignore commits pushed usingGITHUB_TOKEN
). This more-or-less works, but it's a lot of work to replicate this set up across dozens of repositories, and it's really abusing a bunch of unrelated functionality for something that should be available out of the box.My proposed solution is to add a checkbox under Branch Protection rules, "Allow Github Actions workflows run from matching branches to push commits back to the same branch". Checking this box would have two effects:
push
events to the protected branch (which, given the branch is protected, will generally represent pull-request merges rather than remote pushes) will be allowed to push additional commits back to the protected branch as if they were being pushed by an individual user who was listed under "Restrict who can push to matching branches".workflow_dispatch
event, where the workflow was dispatched from the protected branch (i.e. the workflow YAML file being executed is read from the protected branch) will be allowed to push additional commits back to the protected branch as if they were being pushed by an individual who was listed under "Restrict who can push to matching branches".Note that in both cases, the workflow should only be permitted to push commits back to the same branch that the workflow is being executed from (or other, unprotected branches, as is already possible). A workflow should not be able to push commits to any other protected branch, not even a distinct branch that matches the same branch protection rule.
This feature request is inspired by a long-running discussion in the Github Community discussion boards; I felt it was worth bringing a concrete feature request to this Feedback repository, at this point.
NOTE: If you want to show your support for this feature request, please upvote it using the upvote button

rather than replying with a "+1". Replies like that just result in sending spam to everyone else interested in the issue, and importantly, don't even "count" when it comes to how much GitHub will prioritize the issue. They're just spam, they're not spam that also counts as a vote in any way.
Beta Was this translation helpful? Give feedback.
All reactions