能在 push 代码的时候执行某些操作,同时可以通过指定一些参数,使得只在特定的 push,或者 commit message 时才会执行 ci job。
language: node_js
node_js:
- 10
cache:
directories:
- "node_modules"
install:
- npm i
script:
- npm run build
after_success:
- cd .docz/dist
- git init
- git config --global user.name "${U_NAME}"
- git config --global user.email "${U_EMAIL}"
- git add -A
- git commit -m 'deploy'
- git push --quiet --force "https://${GH_TOKEN}@${GH_REF}" master:${P_BRANCH}
branches:
except:
- master
branches:
only:
- gh-pages
分别是指定语言,指定 node 版本,指定缓存目录等,同时在 after_success 时,通过命令实现向某个特定 URL 和分支 push 代码。
资料(link:https://devops.stackexchange.com/questions/1201/whats-the-difference-between-travis-ci-org-and-travis-ci-com),即原本 travis-ci.com 用于私人付费项目,travis-ci.org 用于公共免费项目。但18年5月之后都是推荐使用travis-ci.com(link:https://travis-ci.com/). 最近在部署 react-story-book 的时候,发现 travis-ci.com(link:https://travis-ci.com/) 加载不到我的react-story-book仓库,而 travis-ci.org(link:https://travis-ci.org/) 可以,因此又使用了travis-ci.org。
branches相关配置资料(link:https://docs.travis-ci.com/user/customizing-the-build#building-specific-branches),即默认 gh-pages 分支不会执行 ci job,除非手动添加到白名单。
branches:
only:
- gh-pages

