You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
remote: error: GH006: Protected branch update failed for refs/heads/dev.
remote: error: At least 1 approving review is required by reviewers with write access. You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
Hi @nodesocket, that case is currently not yet supported, but I've already fixed that bug (not yet merged). If you want to try it out, you can switch the used version to ad-m/github-push-action@74d8e0b6f0b86b61232a9b3a28b45bf8a5593532. It would be nice to give me feedback about the functionality and everything works as expected.
@ZPascal no luck using this commit hash, but I did not specify force: true. Is that required?
remote: error: GH006: Protected branch update failed for refs/heads/dev.
remote: error: At least 1 approving review is required by reviewers with write access. You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
Hi @nodesocket, I've reproduced the case in a GitHub Enterprise instance and found a solution. Could you please share the checkout step and add the token to the checkout functionality?
Be aware, please use token as the key for the checkout action and not github_token.
@ZPascal amazing!!! Thanks 🙇🏻 so much. Adding token to the checkout step worked. Let me know when this is merged in so I can use master again instead of 74d8e0b6f0b86b61232a9b3a28b45bf8a5593532.
@ZPascal is this live by chance? Also, any workaround you can think of when we have multiple actions running that do a push to the repo? The issue is that the checkout happens before the other action pushes thus getting:
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
Unfortunately, not yet. I'll ping a few reviewers and hope we can merge it asap.
Also, any workaround you can think of when we have multiple actions running that do a push to the repo? The issue is that the checkout happens before the other action pushes thus getting:
Normally the push action uses the --atomic parameter (It's necessary to use Git >= 2.4.0). Theoretically, it's also possible to execute beforehand a manual pull like the following example.
- name: Run git pull beforehand
run: git pull
Could you please share the debug output of the action? That would help the further analyse the case.
The problem (I think) is that multiple GitHub actions can get triggered simultaneously each independently calling checkout and then at different times trying to push later on when another action may have already committed and pushed.
Note that the bash script updateimagetags.sh does the following at the very end, so it should be pulling in changes.
git config --local user.name "machine-user"
git config --local user.email "[email protected]"
git add --all
git commit -am "[gh-action] image tag for $APPLICATIONS to $IMAGE_TAG"
git pull --rebase
@ZPascal actually I think I see it. When it's trying to push, it's not pushing the branch it checked out I think it is defaulting to dev.
# from updateimagetags.sh
Current branch production is up to date.
But then this GitHub action is trying to push to dev branch:
Run ad-m/github-push-action@74d8e0b6f0b86b61232a9b3a28b45bf8a5593532
Push to branch dev
Pushing to https://github.com/Acme/App.git
To https://github.com/Acme/App.git
! [rejected] HEAD -> dev (non-fast-forward)
error: failed to push some refs to 'https://github.com/Acme/App.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: Invalid exit code: 1
How can I specify it should push the branch that is checked out?
@nodesocket Is your default branch dev? This explains the case, because the default branch for the checkout action is the default repository branch.
You can specify the branch by adding the branchparameter input to the action. For example, it is possible to specify the appropriate branch by adding ${{ github.ref }} or, if you are using the action within a PR, with ${{ github.head_ref }}. In general, I recommend setting up the appropriate branch within the checkout action.
Update:You can also use now the master branch. I've merged the PR. I've reverted the change, because it results in issues. It's necessary to further analyze it. I've opened a PR to deliver a bug fix. I think you can use again the master version.
Hi @nodesocket, I reverted the original change a few days ago. In the meantime, I have already placed and merged a new fix that includes the original change and the corresponding bug fix. You can switch to the master version.
Activity
ZPascal commentedon Apr 21, 2023
Hi @nodesocket, that case is currently not yet supported, but I've already fixed that bug (not yet merged). If you want to try it out, you can switch the used version to
ad-m/github-push-action@74d8e0b6f0b86b61232a9b3a28b45bf8a5593532. It would be nice to give me feedback about the functionality and everything works as expected.nodesocket commentedon Apr 21, 2023
@ZPascal awesome will try it. Do I need to set
force: true?nodesocket commentedon Apr 21, 2023
@ZPascal no luck using this commit hash, but I did not specify
force: true. Is that required?ZPascal commentedon Apr 22, 2023
Hi @nodesocket, from my understanding, that should not be required. I'll set up a test system and debug it.
nodesocket commentedon Apr 22, 2023
@ZPascal thanks. Let me know what you find
nodesocket commentedon Apr 26, 2023
@ZPascal were you able to find anything? Still failing for us. The machine user simply has a legacy personal access token with no expiration.
Then in the GitHub action doing:
ZPascal commentedon Apr 27, 2023
Hi @nodesocket, I've reproduced the case in a GitHub Enterprise instance and found a solution. Could you please share the checkout step and add the token to the checkout functionality?
Be aware, please use
tokenas the key for the checkout action and notgithub_token.nodesocket commentedon Apr 28, 2023
@ZPascal amazing!!! Thanks 🙇🏻 so much. Adding
tokento the checkout step worked. Let me know when this is merged in so I can usemasteragain instead of74d8e0b6f0b86b61232a9b3a28b45bf8a5593532.Once again, appreciate it....
ZPascal commentedon Apr 30, 2023
@nodesocket Sure, I'll update you.
nodesocket commentedon May 17, 2023
@ZPascal is this live by chance? Also, any workaround you can think of when we have multiple actions running that do a push to the repo? The issue is that the checkout happens before the other action pushes thus getting:
Is there a way to say
pullbefore doing:ZPascal commentedon May 17, 2023
Hi @nodesocket,
Unfortunately, not yet. I'll ping a few reviewers and hope we can merge it asap.
Normally the push action uses the
--atomicparameter (It's necessary to use Git >= 2.4.0). Theoretically, it's also possible to execute beforehand a manual pull like the following example.Could you please share the debug output of the action? That would help the further analyse the case.
nodesocket commentedon May 17, 2023
So the GH action does a flow like:
The problem (I think) is that multiple GitHub actions can get triggered simultaneously each independently calling checkout and then at different times trying to push later on when another action may have already committed and pushed.
Note that the bash script
updateimagetags.shdoes the following at the very end, so it should be pulling in changes.nodesocket commentedon May 17, 2023
@ZPascal actually I think I see it. When it's trying to push, it's not pushing the branch it checked out I think it is defaulting to
dev.But then this GitHub action is trying to push to
devbranch:How can I specify it should push the branch that is checked out?
ZPascal commentedon May 18, 2023
@nodesocket Is your default branch
dev? This explains the case, because the default branch for the checkout action is the default repository branch.You can specify the branch by adding the
branchparameter input to the action. For example, it is possible to specify the appropriate branch by adding${{ github.ref }}or, if you are using the action within a PR, with${{ github.head_ref }}. In general, I recommend setting up the appropriate branch within the checkout action.Update:
You can also use now the master branch. I've merged the PR. I've reverted the change, because it results in issues. It's necessary to further analyze it.I've opened a PR to deliver a bug fix. I think you can use again the master version.ZPascal commentedon May 26, 2023
@nodesocket Can we close this issue?
nodesocket commentedon May 27, 2023
@ZPascal is the required change now in master? I think you mentioned you had to revert it
ZPascal commentedon May 30, 2023
Hi @nodesocket, I reverted the original change a few days ago. In the meantime, I have already placed and merged a new fix that includes the original change and the corresponding bug fix. You can switch to the master version.