Update Hugo Modules with GitHub Actions

Learn how to use GitHub Actions and Hugo Docker images to update Hugo Modules.

Donate

Become a backer or sponsor to support our work.

On this page

Sponsors

Create Workflow

Create a GitHub workflow with the following template, tweak it and commit the changes.

 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