feat: using docker for gitbook building
- support CircleCI - create docker image - delete wercker Ci - show build status on READMEpull/378/head
parent
cc5eaa056a
commit
8b9986f8e7
|
@ -0,0 +1,36 @@
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
lint-gitbook:
|
||||||
|
docker:
|
||||||
|
- image: jimmysong/gitbook-builder:2019-07-25
|
||||||
|
working_directory: ~/gitbook
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Linting the gitbook
|
||||||
|
command: scripts/lint-gitbook.sh
|
||||||
|
markdown-spell-check:
|
||||||
|
docker:
|
||||||
|
- image: jimmysong/website-builder:2019-07-25
|
||||||
|
working_directory: ~/gitbook
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Running markdown spell check
|
||||||
|
command: scripts/mdspell-check.sh
|
||||||
|
markdown-style-check:
|
||||||
|
docker:
|
||||||
|
- image: jimmysong/website-builder:2019-07-25
|
||||||
|
working_directory: ~/gitbook
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Running markdown style check
|
||||||
|
command: scripts/mdl-check.sh
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
workflow:
|
||||||
|
jobs:
|
||||||
|
- lint-gitbook
|
||||||
|
- markdown-spell-check
|
||||||
|
- markdown-style-check
|
42
Makefile
42
Makefile
|
@ -1,36 +1,36 @@
|
||||||
BOOK_NAME := kubernetes-handbook
|
BOOK_NAME := kubernetes-handbook
|
||||||
BOOK_OUTPUT := _book
|
BOOK_OUTPUT := _book
|
||||||
|
image := jimmysong/gitbook-builder:2019-07-25
|
||||||
|
docker := docker run -t -i --sig-proxy=true --rm -v $(shell pwd):/gitbook -w /gitbook -p 4000:4000 $(image)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
gitbook build . $(BOOK_OUTPUT)
|
@$(docker) scripts/build-gitbook.sh
|
||||||
cp images/apple-touch-icon-precomposed-152.png $(BOOK_OUTPUT)/gitbook/images
|
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
|
@$(docker) scripts/lint-gitbook.sh
|
||||||
htmlproofer --url-ignore "/localhost/,/172.17.8.101/,/172.20.0.113/,/slideshare.net/,/grpc.io/,/kiali.io/,/condiut.io/,/twitter.com/,/facebook.com/,/medium.com/,/google.com/,/jimmysong.io/,/openfaas.com/,/linkerd.io/,/layer5.io/,/thenewstack.io/,/blog.envoyproxy.io/,/blog.openebs.io/,/k8smeetup.github.io/,/blog.heptio.com/,/apigee.com/,/speakerdeck.com/,/download.svcat.sh/,/blog.fabric8.io/,/blog.heptio.com/,/blog.containership.io/,/blog.mobyproject.org/,/blog.spinnaker.io/,/coscale.com/,/zh.wikipedia.org/,/labs.play-with-k8s.com/,/cilium.readthedocs.io/,/azure.microsoft.com/,/storageos.com/,/openid.net/,/prometheus.io/,/coreos.com/,/openwhisk.incubator.apache.org/" $(BOOK_OUTPUT)
|
htmlproofer --url-ignore "/localhost/,/172.17.8.101/,/172.20.0.113/,/slideshare.net/,/grpc.io/,/kiali.io/,/condiut.io/,/twitter.com/,/facebook.com/,/medium.com/,/google.com/,/jimmysong.io/,/openfaas.com/,/linkerd.io/,/layer5.io/,/thenewstack.io/,/blog.envoyproxy.io/,/blog.openebs.io/,/k8smeetup.github.io/,/blog.heptio.com/,/apigee.com/,/speakerdeck.com/,/download.svcat.sh/,/blog.fabric8.io/,/blog.heptio.com/,/blog.containership.io/,/blog.mobyproject.org/,/blog.spinnaker.io/,/coscale.com/,/zh.wikipedia.org/,/labs.play-with-k8s.com/,/cilium.readthedocs.io/,/azure.microsoft.com/,/storageos.com/,/openid.net/,/prometheus.io/,/coreos.com/,/openwhisk.incubator.apache.org/" $(BOOK_OUTPUT)
|
||||||
|
|
||||||
.PHONY: serve
|
|
||||||
serve:
|
|
||||||
gitbook serve . $(BOOK_OUTPUT)
|
|
||||||
|
|
||||||
.PHONY: epub
|
|
||||||
epub:
|
|
||||||
gitbook epub . $(BOOK_NAME).epub
|
|
||||||
|
|
||||||
.PHONY: pdf
|
|
||||||
pdf:
|
|
||||||
gitbook pdf . $(BOOK_NAME).pdf
|
|
||||||
|
|
||||||
.PHONY: mobi
|
|
||||||
mobi:
|
|
||||||
gitbook mobi . $(BOOK_NAME).mobi
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
npm install gitbook-cli -g
|
@$(docker) gitbook install
|
||||||
gitbook install
|
|
||||||
gem install html-proofer
|
.PHONY: serve
|
||||||
|
serve:
|
||||||
|
@$(docker) gitbook serve . $(BOOK_OUTPUT)
|
||||||
|
|
||||||
|
.PHONY: epub
|
||||||
|
epub:
|
||||||
|
@$(docker) gitbook epub . $(BOOK_NAME).epub
|
||||||
|
|
||||||
|
.PHONY: pdf
|
||||||
|
pdf:
|
||||||
|
@$(docker) gitbook pdf . $(BOOK_NAME).pdf
|
||||||
|
|
||||||
|
.PHONY: mobi
|
||||||
|
mobi:
|
||||||
|
@$(docker) gitbook mobi . $(BOOK_NAME).mobi
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
BOOK_NAME := kubernetes-handbook
|
||||||
|
BOOK_OUTPUT := _book
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
gitbook build . $(BOOK_OUTPUT)
|
||||||
|
cp images/apple-touch-icon-precomposed-152.png $(BOOK_OUTPUT)/gitbook/images
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
htmlproofer --url-ignore "/localhost/,/172.17.8.101/,/172.20.0.113/,/slideshare.net/,/grpc.io/,/kiali.io/,/condiut.io/,/twitter.com/,/facebook.com/,/medium.com/,/google.com/,/jimmysong.io/,/openfaas.com/,/linkerd.io/,/layer5.io/,/thenewstack.io/,/blog.envoyproxy.io/,/blog.openebs.io/,/k8smeetup.github.io/,/blog.heptio.com/,/apigee.com/,/speakerdeck.com/,/download.svcat.sh/,/blog.fabric8.io/,/blog.heptio.com/,/blog.containership.io/,/blog.mobyproject.org/,/blog.spinnaker.io/,/coscale.com/,/zh.wikipedia.org/,/labs.play-with-k8s.com/,/cilium.readthedocs.io/,/azure.microsoft.com/,/storageos.com/,/openid.net/,/prometheus.io/,/coreos.com/,/openwhisk.incubator.apache.org/" $(BOOK_OUTPUT)
|
||||||
|
|
||||||
|
.PHONY: serve
|
||||||
|
serve:
|
||||||
|
gitbook serve . $(BOOK_OUTPUT)
|
||||||
|
|
||||||
|
.PHONY: epub
|
||||||
|
epub:
|
||||||
|
gitbook epub . $(BOOK_NAME).epub
|
||||||
|
|
||||||
|
.PHONY: pdf
|
||||||
|
pdf:
|
||||||
|
gitbook pdf . $(BOOK_NAME).pdf
|
||||||
|
|
||||||
|
.PHONY: mobi
|
||||||
|
mobi:
|
||||||
|
gitbook mobi . $(BOOK_NAME).mobi
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install:
|
||||||
|
npm install gitbook-cli -g
|
||||||
|
gitbook install
|
||||||
|
gem install html-proofer
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf $(BOOK_OUTPUT)
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo "Help for make"
|
||||||
|
@echo "make - Build the book"
|
||||||
|
@echo "make build - Build the book"
|
||||||
|
@echo "make serve - Serving the book on localhost:4000"
|
||||||
|
@echo "make install - Install gitbook and plugins"
|
||||||
|
@echo "make epub - Build epub book"
|
||||||
|
@echo "make pdf - Build pdf book"
|
||||||
|
@echo "make clean - Remove generated files"
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
## 关于本书
|
## 关于本书
|
||||||
|
|
||||||
|
[![CircleCI](https://circleci.com/gh/rootsongjc/kubernetes-handbook/tree/master.svg?style=svg)](https://circleci.com/gh/rootsongjc/kubernetes-handbook/tree/master)
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://jimmysong.io/kubernetes-handbook">
|
<a href="https://jimmysong.io/kubernetes-handbook">
|
||||||
<img src="cover.jpg" width="50%" height="50%" alt="Kubernetes Handbook——Kubernetes中文指南/云原生应用架构实践手册 by Jimmy Song(宋净超)">
|
<img src="cover.jpg" width="50%" height="50%" alt="Kubernetes Handbook——Kubernetes中文指南/云原生应用架构实践手册 by Jimmy Song(宋净超)">
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
FROM alpine:3.9
|
||||||
|
|
||||||
|
MAINTAINER Jimmy Song <rootsongjc@gmail.com>
|
||||||
|
|
||||||
|
RUN apk add --no-cache bash git curl jq tar libc6-compat g++
|
||||||
|
|
||||||
|
RUN apk add --no-cache nodejs-current-npm && npm install -g markdown-spellcheck webpack webpack-cli
|
||||||
|
|
||||||
|
RUN apk add --no-cache ruby ruby-dev ruby-rdoc && gem install mdl
|
||||||
|
|
||||||
|
# Install html-proofer
|
||||||
|
RUN echo 'gem: --no-document' >> /etc/gemrc
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual build-dependencies \
|
||||||
|
build-base \
|
||||||
|
libcurl \
|
||||||
|
libxml2-dev \
|
||||||
|
libxslt-dev && \
|
||||||
|
apk add --no-cache --update build-base libffi-dev && \
|
||||||
|
gem install nokogiri -- --use-system-libraries && \
|
||||||
|
gem install ffi && \
|
||||||
|
gem install etc && \
|
||||||
|
gem install bigdecimal && \
|
||||||
|
gem install html-proofer --no-ri --no-rdoc && \
|
||||||
|
apk del build-dependencies && \
|
||||||
|
apk add --no-cache bash git libcurl libxml2 libxslt && \
|
||||||
|
rm -rf /var/cache/apk/* && \
|
||||||
|
rm -rf /root/.gem/* && \
|
||||||
|
rm -rf /usr/local/bundle/cache/*.gem && \
|
||||||
|
rm -rf /usr/lib/ruby/gems/*/cache/*.gem
|
||||||
|
|
||||||
|
# Install gitbook
|
||||||
|
RUN npm install gitbook-cli -g && \
|
||||||
|
npm install gitbook -g
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
gitbook build
|
||||||
|
cp images/apple-touch-icon-precomposed-152.png _book/gitbook/images
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
BOOK_OUTPUT="./_book"
|
||||||
|
./scripts/build-gitbook.sh
|
||||||
|
echo -ne "mdspell "
|
||||||
|
mdspell --version
|
||||||
|
echo -ne "mdl "
|
||||||
|
mdl --version
|
||||||
|
htmlproofer --version
|
||||||
|
htmlproofer --url-ignore "/localhost/,/172.17.8.101/,/172.20.0.113/,/slideshare.net/,/grpc.io/,/kiali.io/,/condiut.io/,/twitter.com/,/facebook.com/,/medium.com/,/google.com/,/jimmysong.io/,/openfaas.com/,/linkerd.io/,/layer5.io/,/thenewstack.io/,/blog.envoyproxy.io/,/blog.openebs.io/,/k8smeetup.github.io/,/blog.heptio.com/,/apigee.com/,/speakerdeck.com/,/download.svcat.sh/,/blog.fabric8.io/,/blog.heptio.com/,/blog.containership.io/,/blog.mobyproject.org/,/blog.spinnaker.io/,/coscale.com/,/zh.wikipedia.org/,/labs.play-with-k8s.com/,/cilium.readthedocs.io/,/azure.microsoft.com/,/storageos.com/,/openid.net/,/prometheus.io/,/coreos.com/,/openwhisk.incubator.apache.org/" $(BOOK_OUTPUT)
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
FAILED=0
|
||||||
|
|
||||||
|
echo -ne "mdl "
|
||||||
|
mdl --version
|
||||||
|
|
||||||
|
# This performs markdown style check over changed markdown files
|
||||||
|
check_pull_request_content() {
|
||||||
|
|
||||||
|
# only check pull request, skip others
|
||||||
|
if [[ -z $CIRCLE_PULL_REQUEST ]]; then
|
||||||
|
echo "Skip, only check pull request."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get changed files of this PR
|
||||||
|
CIRCLE_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/}
|
||||||
|
OWNER=$(echo $CIRCLE_PULL_REQUEST | cut -d / -f 4)
|
||||||
|
REPO=$(echo $CIRCLE_PULL_REQUEST | cut -d / -f 5)
|
||||||
|
URL="https://api.github.com/repos/$OWNER/$REPO/pulls/$CIRCLE_PR_NUMBER/files"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Getting list of changed markdown files..."
|
||||||
|
CHANGED_MARKDOWN_FILES=()
|
||||||
|
while IFS=$'\n' read -r line; do
|
||||||
|
CHANGED_MARKDOWN_FILES+=( "${line}" )
|
||||||
|
done < <(curl --retry 20 -s -X GET -G $URL | jq '.[] | select(.status != "removed") | select(.filename | endswith(".md")) | .filename')
|
||||||
|
echo "Total changed markdown files: ${#CHANGED_MARKDOWN_FILES[@]}"
|
||||||
|
echo "${CHANGED_MARKDOWN_FILES[@]}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [[ "${#CHANGED_MARKDOWN_FILES[@]}" != "0" ]]; then
|
||||||
|
echo "${CHANGED_MARKDOWN_FILES[@]}" | xargs mdl --ignore-front-matter --style mdl_style.rb
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
FAILED=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No changed markdown files to check."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_pull_request_content
|
||||||
|
|
||||||
|
if [[ $FAILED -eq 1 ]]; then
|
||||||
|
echo "MARKDOWN STYLE CHECK FAILED"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "MARKDOWN STYLE CHECK SUCCEEDED"
|
||||||
|
fi
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
FAILED=0
|
||||||
|
|
||||||
|
echo -ne "mdspell "
|
||||||
|
mdspell --version
|
||||||
|
|
||||||
|
# This performs markdown spell check over changed markdown files
|
||||||
|
check_pull_request_content() {
|
||||||
|
|
||||||
|
# only check pull request, skip others
|
||||||
|
if [[ -z $CIRCLE_PULL_REQUEST ]]; then
|
||||||
|
echo "Skip, only check pull request."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get changed files of this PR
|
||||||
|
CIRCLE_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/}
|
||||||
|
OWNER=$(echo $CIRCLE_PULL_REQUEST | cut -d / -f 4)
|
||||||
|
REPO=$(echo $CIRCLE_PULL_REQUEST | cut -d / -f 5)
|
||||||
|
URL="https://api.github.com/repos/$OWNER/$REPO/pulls/$CIRCLE_PR_NUMBER/files"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Getting list of changed markdown files..."
|
||||||
|
CHANGED_MARKDOWN_FILES=()
|
||||||
|
while IFS=$'\n' read -r line; do
|
||||||
|
CHANGED_MARKDOWN_FILES+=( "${line}" )
|
||||||
|
done < <(curl --retry 20 -s -X GET -G $URL | jq '.[] | select(.status != "removed") | select(.filename | endswith(".md")) | .filename')
|
||||||
|
echo "Total changed markdown files: ${#CHANGED_MARKDOWN_FILES[@]}"
|
||||||
|
echo "${CHANGED_MARKDOWN_FILES[@]}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [[ "${#CHANGED_MARKDOWN_FILES[@]}" != "0" ]]; then
|
||||||
|
echo "${CHANGED_MARKDOWN_FILES[@]}" | xargs mdspell --en-us --ignore-acronyms --ignore-numbers --no-suggestions --report
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
FAILED=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No changed markdown files to check."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_pull_request_content
|
||||||
|
|
||||||
|
if [[ $FAILED -eq 1 ]]; then
|
||||||
|
echo "Feel free to add the term(s) into our glossary file '.spelling'."
|
||||||
|
echo "SPELL CHECK FAILED"
|
||||||
|
else
|
||||||
|
echo "SPELL CHECK SUCCEEDED"
|
||||||
|
fi
|
|
@ -1,9 +0,0 @@
|
||||||
box: billryan/gitbook:base
|
|
||||||
build:
|
|
||||||
steps:
|
|
||||||
- script:
|
|
||||||
name: build
|
|
||||||
code: |
|
|
||||||
make install
|
|
||||||
make build
|
|
||||||
make lint
|
|
Loading…
Reference in New Issue