A GitHub action for keeping hugo modules up to date on a hugo project.
Sets up hugo-extended at the latest version and calls hugo mod get -u
against the project root, recording the updates in its output.
Particularly useful when paired with the create-pull-request action to automatically submit a PR with the changes to the repository or as a step before building/testing a hugo site.
- uses: actions/checkout@v2
- name: Update hugo modules
uses: hugo-module-update@v1
You can also pin to a specific release version in the format @v1.2.3
Name | Description | Default |
---|---|---|
recursive |
Whether or not to update the modules recursively | true |
no-install |
Specify to skip the hugo install step | false |
The following output can be used by subsequent workflow steps.
results
- the JSON representation of text output from runninghugo mod get -u
; must be unwrapped with thefromJSON
when used in a subsequent step.
The default behavior of this action is to install the latest version of hugo-extended
and call hugo mod get -u ./...
against the root folder of the project.
This action does change the files in the working directory of the project, if the update process itself makes any changes to go.mod
or go.sum
.
If the no-install
parameter is specified as true
, it will skip installing hugo-extended.
If the recursive
parameter is specified as false
, it will instead run hugo mod get -u
The following workflow explicates all of the parameters for reference purposes. Check the defaults to avoid setting inputs unnecessarily.
jobs:
buildWithLatestModules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 0.92.2
extended: true
- name: Update Hugo Modules
id: update-hugo-modules
uses: platenio/action-hugo-module-update@v1
with:
recursive: false
no-install: true
- name: List Hugo Module Updates
# Note the use of fromJSON() to parse and write the results
run: "${{ fromJSON(steps.update-hugo-modules.outputs.results) }}"
- name: Build Site with Hugo
id: build-site
run: hugo
The following workflow is an example of using this action to keep your hugo project repository's dependencies up to date on a schedule; it uses the create-pull-request action for the last step.
name: Update Hugo Modules
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
jobs:
update_project_hugo_deps:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Update Hugo Modules
id: update-hugo-modules
uses: platenio/action-hugo-module-update@v1
- name: Create Pull Request
id: createpr
uses: peter-evans/create-pull-request@v3
with:
commit-message: (MAINT) Update Hugo Modules
title: (MAINT) Update Hugo Modules
# Note the use of fromJSON() to retrieve the multi-line string
# and render it as such in the body.
body: |
Dependency updates:
```text
${{ fromJSON(steps.update-hugo-modules.outputs.results) }}
```
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-hugo-modules
base: main
delete-branch: true