Closed andy-maier closed 9 months ago
Some more info:
When pushing a new protected branch using git commands, it depends on who you are, it seems.
With admin permissions in a local command line, it works with a warning:
$ git push --set-upstream origin stable_debug_git
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Bypassed rule violations for refs/heads/stable_debug_git:
remote:
remote: - 2 of 2 required status checks have not succeeded: 1 expected.
remote:
remote:
remote: Create a pull request for 'stable_debug_git' on GitHub by visiting:
remote: https://github.com/zhmcclient/python-zhmcclient/pull/new/stable_debug_git
remote:
To github.com:zhmcclient/python-zhmcclient.git
* [new branch] stable_debug_git -> stable_debug_git
branch 'stable_debug_git' set up to track 'origin/stable_debug_git'.
When using the same git command in a Github Actions workflow, it fails:
Run git push --set-upstream origin stable_debug_git
git push --set-upstream origin stable_debug_git
shell: /usr/bin/bash -e {0}
env:
GITHUB_TOKEN: ***
remote: error: GH006: Protected branch update failed for refs/heads/stable_debug_git.
remote: error: 2 of 2 required status checks have not succeeded: 1 expected. You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
To https://github.com/zhmcclient/python-zhmcclient
! [remote rejected] stable_debug_git -> stable_debug_git (protected branch hook declined)
error: failed to push some refs to 'https://github.com/zhmcclient/python-zhmcclient'
Error: Process completed with exit code 1.
The GITHUB_TOKEN used in the workflow is my personal token, so it should resolve to running the command under my userid and thus should have the same permissions as when running this locally.
Can someone explain that?
Some more investigation:
It seems that the branch creation works if the "Restrict pushes that create matching branches" checkmark in the branch protection rules for "stable_*" is not set. I had that set in this particular project, and have now turned it off.
I am closing this ticket. The somewhat unclear error message is not the fault of this project - it is the same one that gets displayed when using git in the command line.
Describe the bug
Using github.rest.git.createRef to create a protected branch fails with HTTP status 422:
When I do this with an unprotected branch, the branch can be created with the actions plugin.
Creating a protected branch with git commands succeeds.
With an earlier release of this actions plugin, creating protected branches also has worked fine.
Note: With "creating a protected branch" I mean creating a branch that has a name for which a branch protection rule exists that matches the name.
An example of the failure is here: https://github.com/zhmcclient/python-zhmcclient/actions/runs/7941520871
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Protected branches can be created without error.
Screenshots N/A
Desktop (please complete the following information):
Smartphone (please complete the following information): N/A
Additional context N/A