docusaurus: gh_pages publish error
Environment
OS: ubuntu 17.10 Node: v6.11.4 npm: 5.6.0 yarn: 1.3.2 (OS, Node, npm, yarn)
Steps to Reproduce
-
publish use local project to remote use : yarn run publish-gh-pages command, first time is ok, but when checkout the second time fail;
-
error info shows:
$ docusaurus-publish master generate.js triggered… feed.js triggered… feed.js triggered… Site built successfully. Generated files in ‘build’ folder. Cloning into ‘fartpig.github.io-master’… git clone ok Note: checking out ‘origin/master’.
You are in ‘detached HEAD’ state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 254a030… Delete CNAME fatal: A branch named ‘master’ already exists. fatal: could not set upstream of HEAD to origin/master when it does not point to any branch. Error: Git checkout master failed error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
-
when i git log the branch , they has the same SHA code between the detached commit and master branch.
When I note the code :
if (shell.exec(`git checkout origin/${DEPLOYMENT_BRANCH}`).code !== 0) {
if (shell.exec(`git checkout --orphan ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
} else {
if (
shell.exec(`git checkout -b ${DEPLOYMENT_BRANCH}`).code +
shell.exec(`git branch --set-upstream-to=origin/${DEPLOYMENT_BRANCH}`)
.code !==
0
) {
shell.echo(`Error: Git checkout ${DEPLOYMENT_BRANCH} failed`);
shell.exit(1);
}
}
in docusaurus-publish.js , then it works. I thinks this should have a branch check before operation.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (15 by maintainers)
HI @wang701 I just published to my user site. You need to make sure you set the branch to
sourcewhen you publish:e.g, my command was:
Also make sure you have the right settings in your
siteConfig.jsfor your project and org. e.g., mine is:Let me know if this helps you.
Given that #716 gives the correct error message and I see
Docusaurus also supports deploying user or organization sites. These sites will be served from the master branch of the repo. So, you will want to have the Docusaurus infra, your docs, etc. in another branch (e.g., maybe call it source). To do this, just set projectName to "username.github.io" (where username is your username or organization name on GitHub) and organizationName to "username". The publish script will automatically deploy your site to the root of the master branch to be served.At https://docusaurus.io/docs/en/publishing.html#using-github-pagesI think less user will find this error. Should we close this @joelmarcey @yangshun?
@wang701 Would you be keen to create a PR to update the documentation?
@JoelMarcey 's solution work for me, but I need to remove my
masterbranch and set default branch tosource.@JoelMarcey I looked into
publish-gh-pages.jsagain. For this particular block,It means that if the first
git checkout origin/${DEPLOYMENT_BRANCH}return code is 0, the script goes to theelseblock and tries to make a another${DEPLOYMENT_BRANCH}branch which causes the error @t3573393 and I are experiencing. I am confused by code in theelseblock.My rewrite is this:
And it works for me.