-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Force pushing risks losing data #1052
Comments
Something similar to this issue was raised in #1000. Would adding a concurrency param to the workflow be an appropriate workaround for this? If not I'd be happy to review a pull request and provide guidance if you'd like. I think this would be a good thing to figure out at the project level if it can be made fail safe. |
You're right, it looks like this and #1000 refer to the same root issue.
In fact if a user knows that they're using this action for more than 2 deployments, they should avoid the
I also discussed this here: https://github.community/t/avoiding-conflicts-when-two-workflows-push-to-the-same-branch/233774/3?u=rossjrw I'll raise a PR in the near future, likely gated behind a flag for now. |
Awesome. Thanks for the context! I will keep an eye out for the pull request. |
It looks like this action implements its changes by force-pushing to the target branch:
github-pages-deploy-action/src/git.ts
Lines 220 to 221 in 226f2c4
I believe this works for the vast majority of use cases, but not all of them. In the case where two deployments to different locations on the same branch are initiated at the same time (or perhaps just very close to each other), changes could be destroyed.
Details about my specific use case
Consider a use case where this action is being used to create multiple deployments in different directories in a single branch - for example, a main
gh-pages
deployment and a preview deployment for a pull request:This repository would have one workflow that creates the main deployment on push to the main branch:
And another that handles preview deployments for pull requests - both setting them up for
opened
/closed
/synchronize
events, and removing them onclosed
events:This is where the action's current assumption that all deployments will neatly overwrite the previous deployment breaks down. When a pull request is merged to the main branch, the pull request's
closed
event and the main branch'spush
event will fire at the same time. This causes two simultaneous deployments.Both deployments will pull and secure a reference to the current SHA of the
gh-pages
branch. They'll prepare their commit, and then push. Normally, one would be successful and the other would fail, but in this case both force-push their changes and one of the commits will be destroyed.In my case, I merged a pull request, the preview for the pull request was successfully removed, and the main deployment was lost.
I believe this could be resolved by changing how the action pushes its changes. Rather than force-push the deployment, I think it should attempt a regular push then, if that fails, pull the remote and push again just like a human would.
An implementation that does this forever until it pushes successfully could look something like this:
Do you think this would work / is a good idea? Have I misdiagnosed the issue; or is there a better way of resolving it?
I'm happy to work on this as a PR - I need this functionality, so I'll be mucking about in a fork regardless. Please do let me know if you have any thoughts.
The text was updated successfully, but these errors were encountered: