Github Actions + Hexo + Github Page 搭建博客

2019-10-16 05:42:37 +08:00
 waterlaw

Github Page 只能在 master 分支发布, 且仓库名必须为[用户名]-github.io, 所以 Hexo 配置我放在 dev 分支,github action

定义了一个 workflow, 放在项目的 .github/workflows/nodejs.yml , 使用执行完 yml workflow 流程就会生成到 master 分

支, 执行完脚本的 master 分支就是博客的 html/css/js。

参考 github action https://github.com/JamesIves/github-pages-deploy-action,

我的 blog 配置仓库 https://github.com/water-law/water-law.github.io

yml: https://github.com/water-law/water-law.github.io/blob/dev/.github/workflows/nodejs.yml

ps: 记得把 头像->profile->Developer settings->Personal access tokens 复制到项目 settings->Secrets

github action: nodejs.yml 如下

name: GitHub Actions Build and Deploy Demo
on:
  push:
    branches:
      - dev
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@master

    - name: Build and Deploy
      uses: JamesIves/github-pages-deploy-action@master
      env:
        ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
        BASE_BRANCH: dev
        BRANCH: master
        FOLDER: public
        BUILD_SCRIPT: npm i -g hexo && npm install && hexo generate

6426 次点击
所在节点    分享发现
21 条回复
thet
2019-10-16 12:01:01 +08:00
@bequt #15 非常稳定

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/609744

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX