Closed sasial-dev closed 3 years ago
The problem you're seeing is because Github makes a shallow checkout when you use actions/checkout@v2
, which means that when mike
tries to do its thing on the gh-pages
branch, it thinks it's a brand-new, empty branch. That works fine until pushing upstream, when it fails for the reason you see.
The easiest solution I know of is to add the following to your checkout action:
uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all commits/branches
There are some more details in this issue as well.
There might be a better way to do this (which is why I haven't officially-recommended the above in the README), but it should work for you. If not, just let me know. I'll also try and figure out a proper solution to put in the README (or maybe even do something like this automatically?) since it's a subtle issue that tends to trip people up.
Thanks so much!
Hmm, I implimented it but I've still got errors
https://github.com/Lundstrong/LundstrongOrders/blob/docs/.github/workflows/push-deploy.yml - here is the link so I don't spam the thread with the yml file I'm getting the same error.
You probably want to get rid of --rebase
in the mike
command. I don't think that's necessary in your case and it might be causing problems. If nothing else, mike
should provide more informative messages about the remote branch status without --rebase
.
If that doesn't work, then you can try seeing whether your CI's version of gh-pages
is right. Just add git log gh-pages -n1
somewhere and make sure the commit ID looks right and that it's on both your local gh-pages
as well as origin/gh-pages
. It should look something like:
commit <id> (origin/gh-pages, gh-pages)
Oh, I'm also a little concerned about this bit:
git remote rm origin
git remote add origin "${remote_repo}"
I'm not totally sure what you're trying to do here, but I think it would mean that the fetch-depth
solution I posted above won't work for you. If you run git remote rm origin
and add a new origin
, I don't think you'll have origin/gh-pages
anymore. Thus, you're (probably) running into the same issue again: mike
thinks gh-pages
is a brand-new branch with no commits and then things fail when you try to push because your local gh-pages
is unrelated to origin/gh-pages
.
If you need the rm origin
/add origin
stuff, you could probably solve the problem by adding git fetch origin/gh-pages
after it. Then you can remote the fetch-depth
stuff from your checkout action.
Ah okay. Was trying to fix the git.name and whatnot and "stole" that from #49 I'll remove rebase and experiment with the origin. Thanks again, I'll get back to you.
Thanks! Works now Removed the origin and rebase.
I have a GH Action
and I am getting the error
How do I fix this, I've looked through the other issues and found no soulution.