NeonFlow 知识库

Ops Lab 2024-02-12 1 分钟

用 GitHub Actions 自动部署 Hugo

#CI/CD #GITHUB ACTIONS #HUGO
用 GitHub Actions 自动部署 Hugo

借助 GitHub Actions,我们可以在推送代码时自动执行 hugo 构建并将 public/ 发布到 Pages 或对象存储。

工作流示例

name: Deploy Hugo
on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.119.0'
      - run: hugo --minify
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

小贴士