This article was not translated to English, It will be done in few days. It would be nice if you can help me to translate.
每次增加新文章时,还需手动更新到github上,重复劳动可以交由工具完成。
Travis CI就是一个帮助我们完成自动构建的工具
我想做的不仅是将编译后的public
文件夹发布到Github Pages上,这样会覆盖掉很多其他文件,所以我只是想将它发布到blog
文件夹下,所以我的.travis.yml
长这样:
.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
|
# https://docs.travis-ci.com/user/deployment/pages/
# https://docs.travis-ci.com/user/languages/python/
language: python
python:
- "3.6"
install:
- uname -a
- wget https://github.com/gohugoio/hugo/releases/download/v0.42.2/hugo_0.42.2_Linux-64bit.deb
- sudo dpkg -i hugo*.deb
- hugo version
- rm -rf blog
- ls
- pwd
script:
- hugo -d blog
- echo 'Hugo build done!'
after_success:
- git config --global user.email "allenforuse@gmail.com"
- git config --global user.name "justforuse"
- git clone https://$GITHUB_TOKEN@github.com/justforuse/justforuse.github.io.git container
- rm -rf container/blog
- cp -r blog container
- cd container
- ls
- git add .
- git commit -m 'Travis upate blog'
- git push -u origin master
|
这样每次更新code分支代码,travis会自动检测并执行上述脚本,发布编译后结果到master分支的blog文件夹下
Github地址: https://github.com/justforuse/justforuse.github.io
👇 Please leave your comment if you like this.👇