Build gitbook and automatically publish based on gitlab ~
The whole construction process is divided into the following parts: install node,npm deploy gitbook gitlab version 8 or above support pipelines, install on the server, configure gitlab runner.
1. Install node
Curl-sL https://rpm.nodesource.com/setup_6.x | bash-(6.9.5) yum install-y nodejs
two。 Install gitbook
Npm install-g gitbook-cli
3.gitlab-ci implements the CI of gitlab mainly through the new version of pipelines function. Implementation principle: run a gitlab runner on the deployment server, and create A. gitlab-ci.yml file in the root directory of the gitlab project, which mainly stores some running scripts, when new data is push, the code will be executed to achieve continuous integration. Implementation steps: 1. Create a new .gitlab-ci.yml file under the root of the project, as follows
Rspec: script:-gitbook init-gitbook build-sh start.sh
When the project content is updated, the updated content is pull to the deployment server, and then the above code is executed in turn to complete the gitbook update. two。 Install runner on the server
# add yum source repository curl-L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh for gitlab | install runneryum install gitlab-ci-multi-runner for sudo bash#yum
To add runner to the gitlab project, you need the project's token and gitlab's url, run the following code on the server:
Gitlab-ci-multi-runner registerPlease enter the gitlab-ci coordinator URL (e.g. Https://gitlab.com/):your urlPlease enter the gitlab-ci token for this runner:your tokenPlease enter the gitlab-ci description for this runner: [opstest]: Please enter the gitlab-ci tags for this runner (comma separated): opsdoc Whether to run untagged builds [true/false]: [false]: true # I chose true here, otherwise every push would have to tag Whether to lock Runner to current project [true/false]: [false]: Registering runner... Succeeded
Then enter the specific token and url according to the prompt, under Settings-- > CI/CD Pipelines of the project. Then you will see your added runner on the above page. Remember to Whether to run untagged builds [true/false]: select true, otherwise it will be stuck when triggered. Theoretically, it will be deployed once it has been established. You can view the deployment process in Pipelines--- > Pipelines under the project path.