學習如何利用 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