-
Notifications
You must be signed in to change notification settings - Fork 5
/
.travis.yml
86 lines (69 loc) · 2.42 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#Reference from https://github.com/NewFuture/travis-page
sudo: false
dist: trusty
language: node_js
node_js: "6"
addons:
apt:
packages:
- ttf-wqy-microhei
- fonts-arphic-gbsn00lp
- calibre
- xvfb
cache:
directories:
- node_modules # NPM packages
- $HOME/.npm # NPM packages
env:
global: # 使用secure加密方式添加secure字段
- BUILD_PATH: "_book" #the build folder to deploy[生成发布的目录]
- GIT_AUTHOR_NAME: "NewFuture" #username[用户名]
- GH_BRANCH: "gh-pages" #branches to push
# - secure: (encrypted string: GH_TOKEN=xxx])
# auto generation and detection 默认下面变量会自动配置GIT变量
- GIT_AUTHOR_EMAIL: "${GIT_AUTHOR_NAME}@users.noreply.github.com"
- GIT_COMMITTER_NAME: "${GIT_AUTHOR_NAME}"
- GIT_COMMITTER_EMAIL: "${GIT_COMMITTER_NAME}@users.noreply.github.com"
- GIT_REF: "$(git ls-remote --get-url)" #git url
before_script:
- npm i gitbook-cli --cache-min 999999
- npm i svgexport --cache-min 999999
- gitbook install
#下面替换成运行生成命令或者脚本
script:
- gitbook build
- xvfb-run gitbook pdf ./ _book/yyf.pdf
- cp README.md $BUILD_PATH/
#### 下面默认根据配置自动处理不用修改 ####
#运行成功后,把生成目录(BUILD_PATH)下的文件发布到指定分支(GH_BRANCH),
#默认增量修改(只增加不删除),要删除[git add .]改成[git add -A]
after_success:
- cd "${BUILD_PATH}" || cd "${TRAVIS_BUILD_DIR}/${BUILD_PATH}"
- test ${TRAVIS_PULL_REQUEST} == true || git init # not update pull request
- git remote add origin ${GIT_REF} && git fetch origin --depth=1
- if [ "`git branch -r --list origin/${GH_BRANCH}`" ] ; then
git reset origin/${GH_BRANCH};
else
git checkout -b ${GH_BRANCH};
fi;
- git add .
- git commit -m "[skip ci]build $(date -I)" &&git push origin HEAD:${GH_BRANCH} -q
before_install:
# 检查验证方式token或者RSAKEY
- if [ $GH_TOKEN ]; then
GIT_REF=`sed \"s#://#&${GH_TOKEN}@#\"<<<$GIT_REF`;
else
GIT_REF=`sed -e 's#^https://#git@#' -e 's#/#:#'<<<$GIT_REF`;
base64 -d <<<$RSAKEY>~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa;
fi;
# 检查路径不存在时,不存在自动创建
- test -d "$BUILD_PATH" || mkdir -p "$BUILD_PATH"
git: #clone 目录深度 1 提高速度
depth: 1
branches: #only build on master
only:
- master
notifications:
email:
on_failure: change
on_success: change