Travis CI + Hexo + COS 配置
2019年6月20日
之前一直使用Travis CI + Github Pages + Hexo + Cloudflare的方案托管博客,省心速度还将就。最近一段时间CF的443端口出现劣化现象,于是将博客重新迁移回腾讯云对象存储上了。并记录一下配置。
安装hexo-deployer-cos
在package.json下的dependencies中添加:
1 | "hexo-deployer-cos": "^1.0.0" |
配置hexo-deployer-cos
在_config.yml中填写配置信息。由于配置文件会上传到github中,为了安全文件不保存SecretID和SecretKey。
1
2
3
4
5
6
7
deploy:
type: cos
appId: 1234567890
secretId: SecretId
secretKey: SecretKey
bucket: iloft-1234567890
region: ap-shanghai
配置Travis-CI
1 | deploy: |
在Travis-CI项目设置界面中配置环境变量。
修改.travis.yml,与只部署到Github Pages相比,增加了将SecretId与SecretKey替换成为预设的环境变量的sed命令和hexo d命令。完整的部署到COS和Github Pages配置文件:
1 | language: node_js |