forked from rootsongjc/kubernetes-handbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: using docker for gitbook building
- support CircleCI - create docker image - delete wercker Ci - show build status on README
- Loading branch information
1 parent
cc5eaa0
commit 8b9986f
Showing
10 changed files
with
244 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
gitbook build | ||
cp images/apple-touch-icon-precomposed-152.png _book/gitbook/images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.