Add hugo-build composite action
Installs Go + Hugo extended and builds a Hugo site in preview (--buildDrafts --buildFuture, development env) or production mode. Extracted from the MCP repo's blog-preview, deploy-blog, and stage-blog workflows where the ~12-line Go+Hugo install+build block was duplicated. Placing it here (rather than as a local .github/actions/ composite in the MCP repo) means stage-blog.yml can reference it at @main — fork-proof by construction, no two-checkout dance needed when building fork-submitted content.
This commit is contained in:
parent
df3720fc27
commit
2451a73720
1 changed files with 133 additions and 0 deletions
62
hugo-build/README.md
Normal file
62
hugo-build/README.md
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# hugo-build
|
||||
|
||||
Installs Go + Hugo (extended edition) and builds a Hugo site. Preview mode
|
||||
includes drafts and future-dated posts; production mode does not.
|
||||
|
||||
## What it does
|
||||
|
||||
1. Sets up Go (for Hugo modules)
|
||||
2. Downloads and installs Hugo extended from GitHub releases
|
||||
3. Runs `hugo --gc --minify --baseURL <base-url>` in the working directory,
|
||||
adding `--buildDrafts --buildFuture` when `mode: preview`
|
||||
|
||||
Output lands in `<working-directory>/public`.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- The caller must have already checked out the Hugo site source. This action
|
||||
does **not** run `actions/checkout`.
|
||||
|
||||
## Required secrets
|
||||
|
||||
None.
|
||||
|
||||
## Caller workflow requirements
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Permissions** | `contents: read` (for checkout, not for this action) |
|
||||
| **Checkout** | Caller must checkout before calling |
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: modelcontextprotocol/actions/hugo-build@main
|
||||
with:
|
||||
working-directory: blog
|
||||
mode: preview # or: production
|
||||
base-url: /
|
||||
```
|
||||
|
||||
Then deploy `blog/public` however you like (Cloudflare Pages, GitHub Pages, etc.)
|
||||
|
||||
## Inputs
|
||||
|
||||
| Input | Required | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `working-directory` | | `.` | Directory containing `hugo.toml` |
|
||||
| `mode` | | `preview` | `preview` → development env, `--buildDrafts --buildFuture`. `production` → production env, no drafts/future. |
|
||||
| `base-url` | | `/` | Hugo `--baseURL` |
|
||||
| `hugo-version` | | `0.148.0` | Hugo extended version |
|
||||
| `go-version` | | `1.24` | Go version for Hugo modules |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output | Description |
|
||||
|---|---|
|
||||
| `public-dir` | Path to built site (`<working-directory>/public`) |
|
||||
Loading…
Reference in a new issue