|
All checks were successful
/ test-version-input-without-file (push) Successful in -9s
/ test-latest-hugo (push) Successful in -8s
/ test-version-input (push) Successful in -8s
/ test-version-file (push) Successful in -7s
/ test-version-file-precedence (push) Successful in -29s
/ test-custom-version-file (push) Successful in -31s
|
||
|---|---|---|
| .forgejo/workflows | ||
| .devcontainer.json | ||
| action.yaml | ||
| LICENSE | ||
| README.md | ||
setup-hugo
Installs Hugo static site generator for Forgejo CI/CD workflows.
Quick Start
name: Build and Deploy
on:
push:
branches: ["main"]
jobs:
build:
runs-on: docker
steps:
- uses: actions/checkout@v6
- name: Setup Hugo
uses: actions/setup-hugo@v1
- name: Build site
run: hugo --minify
How It Works
This action installs the Hugo extended edition by determining the desired version (from input, version file, or latest release), downloading the corresponding Linux AMD64 Debian package, and installing it. An installed Go toolchain is beneficial when using Hugo Modules. The default runner of the runner-images repository has Go installed by default.
Inputs
| Name | Required | Description | Default |
|---|---|---|---|
version |
No | Hugo version to install (e.g., 0.120.0). Use latest for the newest stable release. |
latest |
version-file |
No | Path to a file containing the Hugo version (overrides version if file exists). |
.hugo-version |
Note
If both
versionand an existingversion-fileare specified, the file takes precedence.
Usage Examples
Example 1: Build with Latest Hugo
name: Build Site
on:
push:
branches: ["main"]
jobs:
build:
runs-on: docker
steps:
- uses: actions/checkout@v6
- name: Setup Hugo
uses: actions/setup-hugo@v1
- name: Build
run: hugo --minify --destination dist
Example 2: Pin Specific Version
name: Build Site
on:
push:
branches: [main]
jobs:
build:
runs-on: docker
steps:
- uses: actions/checkout@v6
- name: Setup Hugo 0.120.0
uses: actions/setup-hugo@v1
with:
version: 0.120.0
- name: Build
run: hugo --minify
Example 3: Version from Custom File
name: Build Site
on:
push:
branches: ["main"]
jobs:
build:
runs-on: docker
steps:
- uses: actions/checkout@v6
- name: Setup Hugo
uses: actions/setup-hugo@v1
with:
version-file: .tool-versions
- name: Build
run: hugo --minify
Create a custom version file (e.g., .tool-versions) in your repository root:
0.120.0
Note
If using the default
.hugo-versionfile, you can omit theversion-fileparameter entirely.
Contributing
We welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch - Make your changes and commit them:
git commit -m "Description of your changes" - Push to your fork:
git push origin feature-branch - Create a pull request.
Guidelines
- Follow the existing code style.
- Write clear and concise commit messages.
- Ensure your changes do not break existing functionality.
- Update documentation as needed.
License
This project is licensed under the terms specified in the LICENSE file.