更好的方法是将 Travis 配置为使用不支持的插件自动部署 jekyll。按照Travis 入门指南为您的 repo 启用 Travis。
script/cibuild
使用以下内容创建
#!/usr/bin/env bash
set -e # halt script on error
bundle exec jekyll build
touch ./_site/.nojekyll # this file tells gh-pages that there is no need to build
.travis.yml
使用以下内容创建(根据需要修改)
language: ruby
rvm:
- 2.3.3
before_script:
- chmod +x ./script/cibuild # or do this locally and commit
# Assume bundler is being used, therefore
# the `install` step will run `bundle install` by default.
script: ./script/cibuild
# branch whitelist, only for GitHub Pages
branches:
only:
- master
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer
sudo: false # route your build to the container-based infrastructure for a faster build
deploy:
provider: pages
skip_cleanup: true
keep-history: true
local_dir: _site/ # deploy this directory containing final build
github_token: $GITHUB_API_KEY # Set in travis-ci.org dashboard
on:
branch: master
部署步骤(每次推送后):
- 将使用我们
script/cibuild
在_site
目录中的自定义脚本创建构建
_site
将被推送到gh-pages
分支。
- github页面将按原样提供站点而无需再次构建它(因为
.nojekyll
文件)
参考:我的存储库https://github.com/armujahid/armujahid.me/正在使用这种方法使用 Travis CI 进行持续集成