-
Notifications
You must be signed in to change notification settings - Fork 6
Manual Deploy
In the case that the auto-deploy system is not working or needs to be tweaked, you can manually deploy the gitbook pages.
It is not recommended to manually deploy the docs site, however it can be done using git.
master branch is the markdown and that gh-pages is the live HTML site. For the repo bandwidth.github.com the main branch is gitbook and the master branch is actually the live HTML site
Make sure that you have any and all changes contained in the master branch. If you know what you're doing and are aware of the side effects of deploying another branch, proceed with caution.
When deploying, you should make sure that you have the latest version of all plugins. The most comprehensive way is to rm -rf the node_modules and fresh install.
$ rm -rf node_modules
$ gitbook installThis ensures that the plugins stored in the node_modules are completely up-to-date.
To deploy the site, we don't need all the features that come with gitbook serve. To generate the static HTML used to drive the site use the build command
$ gitbook buildThe build command creates a _book folder in the same directory as the files. The _book folder contains the rendered HTML that will be uploaded to the gh-pages branch.
In order to preview the site before it goes live, I use a tool called http-server. http-server simply serves up a static site on localhost:8080 which is perfect for our use case. http-server works best when installed via NPM globally.
$ cd _book
$ http-server
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8080
http://10.3.145.209:8080
http://10.3.32.141:8080
Hit CTRL-C to stop the serverFollow the same checklist you would do before merging a pull request. Once finished CTRL-C the http-server. And cd out of the _book directory.
Once the site has been clear and you're back at the root folder, checkout the gh-pages branch.
We're going to copy the contents of the _book directory to the main folder of the project. Essentially overwriting and replacing all the old copies.
$ git checkout gh-pagesI personally use a visual tool to 'copy & paste' the files from _book to the main folder, but you're welcome to use bash or whatever you'd like.
After the copypasta has finished, check the changes and add the files with git.
$ git status
//files changed
$ git add --all
$ git commit -m 'Update site on 3/22/18'Final step is to push the changes to the gh-pages remote on github's servers.
$ git pushOnce the contents have been pushed to github's servers, the site should be live in the next couple minutes.
Be sure to checkout master after the push is finished!!!
$ git checkout master