Hexo自动部署功能
Hexo自动部署功能
起源
- 新公司里面,管控很严只能够访问指定的外网网址,他们是使用的白名单的方式控制访问权限,我自己的域名当然不会在白名单之内了,有名气的github还是被放行的,于是被自己闲置了很久的GitHub又可以用起来了。首先就想到的是将Hexo中的静态文件直接push到GitHub Pages的仓库中,然后在本地试了一下,果然是可以的,然后测试Hexo的depoly功能,其实就是将源码打包生成静态文件然后通过git工具push到GitHub,原理很简单,自己一想,这样就可以将自己的一份源码同时部署到自己的Nginx服务器和GitHub Pages中,这样自己既可以在自己的主站上访问也可以在自己的GitHub Pages上进行访问。
步骤
1
| yarn add hexo-deployer-git
|
- 然后在_config.yml中添加deploy的配置
1 2 3 4
| deploy: type: git repo: https://github.com/Xplorist/Xplorist.github.io branch: master
|
- 在.gitlab-ci.yml中进行修改,将原来的hexo generate修改为现在的hexo clean && hexo deploy
1 2
| - hexo clean && hexo deploy
|
- 还有一个问题,就是在GitRunner所在的服务器上执行hexo deploy的时候会报错,是因为没有设置git的账号和密码,使用putty登录到该服务器,设置一下git记住密码,push这个GitHub Pages所在的公共仓库,然后输入账号密码,后面GitRunner执行的时候就不用再提示输入账号密码了,其实这种方案就是自己为了偷懒,更好的解决方案是配置SSH,使用SSH去提交
1
| git config --global credential.helper store
|
到此,Hexo自动部署的功能就实现了。
- 本文标题:Hexo自动部署功能
- 本文作者:Xplorist
- 创建时间:2021-05-16 13:24:00
-
本文链接:https://xplorist.tech/2021/05/16/5ffb0b62f979/
-
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
$tools-item-width = 2.2rem
$tools-item-font-size = 1.1rem
$tools-item-border-radius = 0.1rem
.side-tools-container {
position relative
.tools-item {
width $tools-item-width
height $tools-item-width
margin-bottom 0.2rem
color var(--default-text-color)
font-size $tools-item-font-size
background var(--background-color)
border-right none
border-radius $tools-item-border-radius
box-shadow 0.1rem 0.1rem 0.2rem var(--shadow-color)
cursor pointer
i {
color var(--default-text-color)
}
&:hover {
color var(--background-color)
background var(--primary-color)
box-shadow 0.2rem 0.2rem 0.4rem var(--shadow-color)
i {
color var(--background-color)
}
}
+keep-tablet() {
width $tools-item-width * 0.9
height $tools-item-width * 0.9
margin-bottom 0.2rem
font-size $tools-item-font-size * 0.9
}
&.rss {
a {
width 100%
height 100%
border-radius $tools-item-border-radius
&:hover {
color var(--background-color)
background var(--primary-color)
box-shadow 0.2rem 0.2rem 0.4rem var(--shadow-color)
}
}
}
}
.side-tools-list {
transform translateX(100%)
opacity 0
transition-t("transform, opacity", "0, 0", "0.2, 0.2", "linear, linear")
.tool-expand-width {
+keep-tablet() {
display none
}
}
&.show {
transform translateX(0)
opacity 1
}
}
.exposed-tools-list {
if (hexo-config('style.scroll.percent.enable') == true) {
.tool-scroll-to-top {
display none
&.show {
display flex
}
&:hover {
.percent {
display none
}
.arrow-up {
display flex
}
}
.arrow-up {
display none
}
.percent {
display flex
font-size 1rem
}
}
}
}
}