参考: https://zellwk.com/blog/github-actions-deploy/
首先博客如果使用hexo搭建, 且借助hexo-deployer-git依赖进行远程上传的话, 则需要将repo设置为ssh方式, https方式是不支持的, 如下
1 | deploy: |
当前样例为, 一个blog_source库(未公开)存储未编译md文档, 走cicd流程之后, 将编译好的资源利用hexo d的方式部署到另一个一个github源仓库(开源库)
首先配置ssh/private key
1 | ssh-keygen -t rsa -b 4096 -C "943915349@qq.com" -f key |
邮箱修改为本人邮箱

复制publickey内容到github源仓库(也就是hexo中远程推送repo的地址)
打开浏览器登录你的github,点击右上角带黄色的头像-->settings-->(personal settings中的)SSH and GPG keys-->new SSH key-->title自己取名,key中粘贴publickey-->Add SSH key-->成功!
在blog_source库中进行操作, 创建一个名为SSH_PRIVATE_KEY的secret,将privatekey内容复制进去,如下

创建一个名为SSH_HOST的secret, 将github.com写入进去. 我们会在之后的操作中将它copy到~/.ssh/known_hosts中
创建actions

我们点击configure后, 进入编辑, 编辑内容如下
1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node |
然后提交, 就会触发ci, 将内容发布到源仓库
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 小五的个人杂货铺!