利用 GitHub Actions 更新 Hugo 模块

学习如何利用 GitHub Actions 和 Hugo 镜像更新 Hugo 模块。

赞助

成为我们的资助者或赞助商,以支持我们的工作。

本页内容

赞助商

创建工作流

用以下模板创建一个 GitHub 工作流,稍加调整并提交修改。

 1name: Hugo Modules
 2
 3permissions:
 4  contents: write
 5  pull-requests: write
 6
 7on:
 8  workflow_dispatch:
 9  schedule:
10    - cron: '0 * * * *'
11
12jobs:
13
14  update:
15    runs-on: ubuntu-latest
16    container:
17      image: hugomods/hugo:go
18    steps:
19      - uses: actions/checkout@v4
20
21      - name: Update modules
22        run: hugo mod get -u
23
24      - name: Tidy modules
25        run: hugo mod tidy
26
27      - uses: actions/upload-artifact@v4
28        with:
29          name: deps-hugo-modules
30          path: |
31            go.sum
32            go.mod            
33
34  commit:
35    needs: update
36    runs-on: ubuntu-latest
37    steps:
38      - uses: actions/checkout@v4
39
40      - uses: actions/download-artifact@v4
41        with:
42          name: deps-hugo-modules
43
44      - name: Create Pull Request
45        uses: peter-evans/create-pull-request@v7
46        with:
47          commit-message: "chore(deps): update modules"
48          branch: deps-hugo-modules
49          title: Update Hugo Modules