自动部署测试

travis-ci 配置

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
language: node_js
node_js: stable

cache:
directories:
- node_modules

before_install:
## - openssl aes-256-cbc -K $encrypted_2dd5ddff7fe3_key -iv $encrypted_2dd5ddff7fe3_iv
## -in id_rsa.enc -out ~/.ssh/id_rsa -d
## - chmod 600 ~/.ssh/id_rsa
## # 配置 ssh
## - eval $(ssh-agent)
## - ssh-add ~/.ssh/id_rsa
# # 配置 git 替换为自己的信息
# - git config user.name "Zricky"
# - git config user.email "zjxshushi@gmail.com"

install:
- npm install
- npm install hexo-cli -g
script:
# - hexo clean& hexo g
- npm run deploy
after_script:
- cd public
- git init
- git config user.name "Zricky"
- git config user.email "zjxshushi@gmail.com"
- git add --all
- git commit -m "更新博文"
- git push --force --quiet "https://${GITHUB_TOKEN}@${GH_REF}" master:master

#deploy:
# provider: pages
# skip_cleanup: true
# local-dir: public
# github_token: ${GITHUB_TOKEN} # Set in the settings page of your repository, as a secure variable
# repo: git@github.com:Zricky/Zricky.github.io.git
# on:
# branch: master
branches: #只有分支提交时触发
only:
- hexo

关于travis的变量

image.png

隐私变量不让再日志中展示即可
或者

1
2
3
env:
global:
- GITHUB_TOKEN:xxxxxx
0%