《Github Action》- 一键push-code,自动构建个人博客站点

273 阅读1分钟
原文链接: chengzhanghu.github.io

个人博客站点,本人使用是hexo.常规的操作就是本地编辑好,然后手动部署。有了GitHub action,就解决了自动化部署问题。
更多关于手动部署,请查阅 Hexo

GitHub 新建个人博客分支my-blog

假设读者已会,不做赘述。
另外提一句,GitHub针对3人一下,支持新建private 分支哦~,这是我的最爱!!

hexo-blog theme上传

之前theme主题,没有上传,构建失败

配置workflow

大致的意思就是,在代码push,触发构建,构建到xxx.github.io master分支上。

on: 
  push:
    branches: 
      - master
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout blog code 
      uses: actions/checkout@v2.0.0
        
    - name: Build and Deploy
      uses:  Forest10/hexo-deploy-action-with-cname@v1.0.0
      env:
        USER_NAME: your name # optional
        EMAIL: your email # optional
        PERSONAL_TOKEN: ${{ secrets.ACCESS_TOKEN }}
        PUBLISH_REPOSITORY: your.github.io # The repository the action should deploy to.
        BRANCH: master  # The branch the action should deploy to.
        PUBLISH_DIR: ./public # The folder the action should deploy.

等待构建