配置Travis-CI 发表于 2019-06-Tue | 阅读次数: 第一步 新增travis 文件.travis.yml1234567891011121314151617181920212223242526272829303132333435363738# 指定语言环境language: node_js# 指定需要sudo权限sudo: required# 指定node_js版本node_js: - 7.9.0# 指定缓存模块,可选。缓存可加快编译速度。cache: directories: - node_modules# 指定博客源码分支,因人而异。hexo博客源码托管在独立repo则不用设置此项branches: only: - hexo before_install: - npm install -g hexo-cli# Start: Build Lifecycleinstall: - npm install - npm install hexo-deployer-git --save# 执行清缓存,生成网页操作script: - hexo clean - hexo generate# 设置git提交名,邮箱;替换真实token到_config.yml文件,最后depoy部署after_script: - git config user.name "yourName" - git config user.email "yourEmail" # 替换同目录下的_config.yml文件中gh_token字符串为travis后台刚才配置的变量,注意此处sed命令用了双引号。单引号无效! - sed -i "s/gh_token/${GH_TOKEN}/g" ./_config.yml - hexo deploy# End: Build LifeCycle第二步 修改下_config.yml文件的deploy节点:12345# 修改前deploy: - type: git repo: git@github.com:xiong-it/xiong-it.github.io.git branch: master123456# 修改后deploy:- type: git # 下方的gh_token会被.travis.yml中sed命令替换 repo: https://gh_token@github.com/xiong-it/xiong-it.github.io.git branch: masterhttps://juejin.im/post/5a1fa30c6fb9a045263b5d2a请作者喝一杯咖啡☕️打赏微信支付