Error: HttpError: Reference already exists
123MwanjeMike opened this issue · comments
I am running this action in a an environment with many jobs running in parallel on GitHub actions but at least 3 in every 10 of the jobs fail with the error Error: HttpError: Reference already exists
. I tried to change the check-out depth as suggested in a similar issue(#531) but the issue still remains.
Any help?
Can you provide some more details about your values?
Do you create a new branch / push in an existing one?
Can you provide some more details about your values?
Do you create a new branch / push in an existing one?
I push to an existing branch. An example is below
- name: Update file
uses: fjogeleit/yaml-update-action@main
with:
valueFile: "k8s/app6/values.yaml"
propertyPath: "image.tag"
value: ${{ env.imageTag }}
branch: myBranch
message: "Update app6 image tag to ${{ env.imageTag }}"
It could be possible that the push to your branch fails for any reason and it tries to create your already existing branch.
I added an info logging to the action to see if the push failed and it falls back to the create mode. If you can run the action again you could check if you see a related log entry.
I get the error message
Error: failed to create branch: HttpError: Reference already exists
Do you see an info log beforehand?
Something like update branch ... failed (error message)
?
So as I expected, it fails to push to your branch and tries to create them - which also failed. The error message from the logging above would be helpful to see the issue of updating your branch.
Oh yes, the full error message is:
update branch myBranch failed (HttpError: Update is not a fast forward), fallback to create branch
https://help.github.com/articles/dealing-with-non-fast-forward-errors
I am not sure if I can help you without the knowledge of the full action and repo structructure.
Do you execute some other logic related to this repository / branch in your action which may cause this issue?
Not really, just the update. Below is the link to the exact usage:
Hm I think the issue could be the multiple call of the action with pushing the change each time. Because the local copy is never updated, the parent sha is always the same and the second push fails because it has the wrong parent sha and would overwrite the first push.
Possible solutions could be:
- Update the file in each step without commit/push the change and commiting / pushing everything together at the end
- Update your local branch after each update with a
git pull
- Call the action only ones and using the
changes
input to update multiple values at once
If nothing of this works maybe a solution would be a new input that allows you to only commit each change and push them at the end but this has to be implemented.
Hi @fjogeleit. Based off what you shared and a few trials I have done, I can confirm that the issue is not with this GitHub action itself but rather the context of use. The solutions proposed solve the problem when the workflow run is sequential rather than parallel(as in my case) manner.
Would it be perhaps possible to implement a (pull/update/commit/push)retry mechanism? This is because rerunning only the failed jobs seems to work rather than running the entire workflow.
Thanks for your feedback, I will have a look if I am able to implement something that could help.
Unfortunately I found not way to update the branch via the JS SDK. Did you try to simple run git fetch
right before the failing action call?
I've tried placing a git fetch
before all the update steps and still had some jobs failing.
I was able to solve the issue using the Wandalen/wretry.action retry action on all the update all occurrences.
- name: Update file
uses: Wandalen/wretry.action@master
with:
action: fjogeleit/yaml-update-action@main
with: |
valueFile: "k8s/app6/values.yaml"
propertyPath: "image.tag"
value: ${{ env.imageTag }}
branch: myBranch
message: "Update app6 image tag to ${{ env.imageTag }}"
okay, great. Thanks for the feedback