-
Notifications
You must be signed in to change notification settings - Fork 4
/
.travis.yml
80 lines (64 loc) · 1.81 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
# language: node_js
# node_js: stable
# cache:
# apt: true
# directories:
# - node_modules
# before_install:
# - npm install hexo-cli -g
# install:
# - npm install
# - npm install hexo-deployer-git --save
# script:
# - hexo clean
# - hexo g
# after_script:
# - git clone ${GH_REF} hexo-public
# - cp -rf public/* hexo-public/
# - cd hexo-public
# - git config user.name "no5ix"
# - git config user.email "no5ix@foxmail.com"
# - git add .
# - git commit -am "Travis CI Auto Builder..."
# - git push origin master
# branches:
# only:
# - master
# env:
# global:
# - GH_REF: https://no5ix:${github_token}@github.com/no5ix/no5ix.github.io.git
# 指定语言环境
language: node_js
# node_js: stable
# 指定需要sudo权限
sudo: required
# 指定node_js版本
node_js:
- 8.12.0
# 指定缓存模块,可选。缓存可加快编译速度。
cache:
directories:
- node_modules
# 指定博客源码分支,因人而异。hexo博客源码托管在独立repo则不用设置此项
branches:
only:
- source
before_install:
- npm install -g hexo-cli
# Start: Build Lifecycle
install:
- npm install
- npm install hexo-deployer-git --save
# 执行清缓存,生成网页操作
script:
- tar -zxvf my_node_modules.tar.gz # 貌似这一句跟上面的 cache 有冲突, 貌似是互斥的...出问题记得改这里
- hexo clean
- hexo generate
# 设置git提交名,邮箱;替换真实token到_config.yml文件,最后depoy部署
after_script:
- git config user.name "no5ix"
- git config user.email "no5ix@foxmail.com"
# 替换同目录下的_config.yml文件中gh_token字符串为travis后台刚才配置的变量GH_TOKEN,
# 注意此处sed命令用了双引号。单引号无效!
- sed -i "s/gh_token/${GH_TOKEN}/g" ./_config.yml
- hexo deploy