Update publish script to create gh-pages branch if it does not exist

This commit is contained in:
Frank Li 2017-08-16 17:36:00 -07:00
parent 120678be05
commit 1f1d1448b2

View file

@ -56,17 +56,23 @@ if (
shell.cd(`${CIRCLE_PROJECT_REPONAME}-gh-pages`);
if (
shell.exec("git checkout origin/gh-pages").code +
if (shell.exec("git checkout origin/gh-pages").code !== 0) {
if (shell.exec("git checkout --orphan gh-pages").code !== 0) {
shell.echo("Error: Git checkout gh-pages failed");
shell.exit(1);
}
} else {
if (
shell.exec("git checkout -b gh-pages").code +
shell.exec("git branch --set-upstream-to=origin/gh-pages").code !==
0
) {
shell.echo("Error: Git checkout gh-pages failed");
shell.exit(1);
shell.exec("git branch --set-upstream-to=origin/gh-pages").code !==
0
) {
shell.echo("Error: Git checkout gh-pages failed");
shell.exit(1);
}
}
shell.exec("rm -rf *");
shell.exec("git rm -rf .");
shell.cd("../..");