部署多个远程托管
由于github
服务器在国外,相应速度慢,同时将代码托管在国内的Coding
和国外的Github
上,使用同一域名,提高相应速度
码云的Pages
服务需要购买服务才能自定义域名,所以推荐使用Coding
Coding
设置
Coding
项目名
定义项目名为
<username>.coding.me
必须定义成上面格式,否则无法设置DNS
解析
Coding Pages
设置
参考:
手把手教你用Hexo+(Coding/GitHub)搭建个人博客及绑定私有域名
将静态文件上传到Coding
后,开启Pages
服务,此时打开网站会出现文件无法解析的情况,需要进一步设置自定义域名
注意:Coding
对于Pages
部署次数有限制
静态 Pages 有部署次数限制,付费会员为每小时可以部署 30 次,非付费会员每小时可以部署 10 次
本地部署
参考:认证
如果在本地使用插件hexojs/hexo-deployer-git进行部署,那么修改工程_config.yml
的deploy
小节
...
url: https://www.zhujian.tech
...
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
- type: git
repo:
github: https://github.com/zjZSTU/zjzstu.github.com.git,master
coding: git@git.dev.tencent.com:zjZSTU/zjZSTU.coding.me.git,master
...
-
设置
url
为自定义域名 -
使用
HTTP
协议传输代码到Github
,使用SSH
协议传输代码到Coding
格式如下:
deploy:
type: git
message: [message]
repo:
github: <repository url>,[branch]
coding: <repository url>,[branch]
远程部署
参考:
Creating a personal access token for the command line
如果通过git
上传代码到Github
,在通过Travis Ci
进行自动部署,那么需要设置传输协议为HTTP
,同时加上个人令牌密码
具体参考[Travis CI]持续集成
工程_config.yml
文件修改如下:
...
url: https://www.zhujian.tech
...
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
- type: git
repo:
github: https://github.com/zjZSTU/zjzstu.github.com.git,master
coding: git@git.dev.tencent.com:zjZSTU/zjZSTU.coding.me.git,master
...
_travis.yml
文件修改如下:
after_success:
- sed -i'' "s~https://github.com/zjZSTU/zjzstu.github.com.git~https://${GITHUB_REPO_TOKEN}@github.com/zjZSTU/zjzstu.github.com.git~" _config.yml
- sed -i'' "s~git@git.dev.tencent.com:zjZSTU/zjZSTU.coding.me.git~https://zjZSTU:${CODING_REPO_TOKEN}@git.coding.net/zjZSTU/zjZSTU.coding.me.git~" _config.yml
- hexo deploy
Coding
注意
Travis CI 自动部署hexo到GitHub/Coding
Coding
仓库当前的HTTP
链接为
https://git.dev.tencent.com/<user-name>/<repo-name>.git
需要进一步改成
https://git.coding.net/<user-name>/<repo-name>.git
否则无法使用,坑!!!