From 16aa42a70532e2269b5e488ade3ad344fd7751a2 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Fri, 17 Nov 2017 14:26:08 -0800 Subject: [PATCH] Allow deploying docs from a branch other than `master` Still have to deploy to `gh-pages` --- docs/getting-started-publishing.md | 4 +++- lib/publish-gh-pages.js | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/getting-started-publishing.md b/docs/getting-started-publishing.md index aa8bd68af3..c286bd8330 100644 --- a/docs/getting-started-publishing.md +++ b/docs/getting-started-publishing.md @@ -34,7 +34,9 @@ Most of the work to publish to GitHub pages is done for you automatically throug - `CIRCLE_PROJECT_USERNAME`: The GitHub user or organization that owns the repository. In the case of Docusaurus, that would be the "facebookexperimental" GitHub organization. - `CIRCLE_PROJECT_REPONAME`: The name of the GitHub repository for your project. For example, Docusaurus is hosted at https://github.com/facebookexperimental/docusaurus, so our repo name in this case would be "docusaurus". - `GIT_USER`: The username for a GitHub account that has commit access to this repo. For your own repositories, this will usually be your own GitHub username. -- `CIRCLE_BRANCH`: The branch that contains the latest docs changes that will be deployed. Usually, "master". +- `CIRCLE_BRANCH`: The branch that contains the latest docs changes that will be deployed. Usually, the branch will be `master`, but it could be any branch (default or otherwise) except for `gh-pages`. + +> We currently require the published documentation to be served from the `gh-pages` branch in your GitHub repo. > The reason we prefix some of these parameters with `CIRCLE` is because Docusaurus recommends publishing your documentation continuously when changes are committed via [CircleCI](https://circleci.org). diff --git a/lib/publish-gh-pages.js b/lib/publish-gh-pages.js index 749ba6bc91..33d753c2ce 100755 --- a/lib/publish-gh-pages.js +++ b/lib/publish-gh-pages.js @@ -31,11 +31,16 @@ if (!shell.which("git")) { shell.exit(1); } -if (CI_PULL_REQUEST || CIRCLE_BRANCH !== `master`) { - shell.echo("Skipping deploy"); +if (CI_PULL_REQUEST) { + shell.echo("Skipping deploy on a pull request"); shell.exit(0); } +if (CIRCLE_BRANCH === "gh-pages") { + shell.echo("Cannot deploy from a gh-pages branch. Only to it"); + shell.exit(1); +} + if (shell.exec(`node ${__dirname}/build-files.js`).code) { shell.echo("Error: generating html failed"); shell.exit(1);