Merge pull request #4 from modelcontextprotocol/den/stageblog-command
Add hugo-build composite action
This commit is contained in:
commit
e2fbc602d7
3 changed files with 133 additions and 0 deletions
|
|
@ -8,4 +8,5 @@ GitHub Actions relevant to the management of MCP repositories.
|
|||
|---|---|
|
||||
| [`cloudflare-pages-preview/deploy`](cloudflare-pages-preview/README.md) | Deploy a static HTML directory to Cloudflare Pages under a per-PR branch alias, inject noindex headers, and post a sticky PR comment with preview URLs |
|
||||
| [`cloudflare-pages-preview/cleanup`](cloudflare-pages-preview/README.md) | Delete Cloudflare Pages deployments for a closed PR's branch alias and update the sticky comment |
|
||||
| [`hugo-build`](hugo-build/README.md) | Install Go + Hugo extended and build a Hugo site (preview or production mode) |
|
||||
| [`slash-commands`](slash-commands/README.md) | Handle `/lgtm`, `/hold`, and `/stageblog` PR slash commands gated by team membership + CODEOWNERS; invalidate approval on push |
|
||||
|
|
|
|||
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`) |
|
||||
70
hugo-build/action.yml
Normal file
70
hugo-build/action.yml
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
name: Hugo Build
|
||||
description: >-
|
||||
Installs Go + Hugo (extended) and builds a Hugo site. Set mode=preview to
|
||||
include drafts and future-dated posts (development env); mode=production
|
||||
for release builds.
|
||||
|
||||
inputs:
|
||||
working-directory:
|
||||
description: Directory containing the Hugo site (with hugo.toml)
|
||||
required: false
|
||||
default: '.'
|
||||
mode:
|
||||
description: >-
|
||||
'preview' (HUGO_ENVIRONMENT=development, --buildDrafts --buildFuture) or
|
||||
'production' (HUGO_ENVIRONMENT=production, no drafts/future)
|
||||
required: false
|
||||
default: preview
|
||||
base-url:
|
||||
description: >-
|
||||
Hugo --baseURL. Typically '/' for CF Pages previews (root-relative
|
||||
paths); pass the canonical URL for production.
|
||||
required: false
|
||||
default: '/'
|
||||
hugo-version:
|
||||
description: Hugo extended version to install
|
||||
required: false
|
||||
default: '0.148.0'
|
||||
go-version:
|
||||
description: Go version for Hugo modules
|
||||
required: false
|
||||
default: '1.24'
|
||||
|
||||
outputs:
|
||||
public-dir:
|
||||
description: Path to the built static site (working-directory + /public)
|
||||
value: ${{ inputs.working-directory }}/public
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
|
||||
- name: Install Hugo
|
||||
shell: bash
|
||||
env:
|
||||
HUGO_VERSION: ${{ inputs.hugo-version }}
|
||||
run: |
|
||||
wget -O "${RUNNER_TEMP}/hugo.deb" \
|
||||
"https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb"
|
||||
sudo dpkg -i "${RUNNER_TEMP}/hugo.deb"
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
env:
|
||||
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
|
||||
HUGO_ENVIRONMENT: ${{ inputs.mode == 'production' && 'production' || 'development' }}
|
||||
BASE_URL: ${{ inputs.base-url }}
|
||||
WORKDIR: ${{ inputs.working-directory }}
|
||||
MODE: ${{ inputs.mode }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${WORKDIR}"
|
||||
args=(--gc --minify --baseURL "${BASE_URL}")
|
||||
if [ "${MODE}" = "preview" ]; then
|
||||
args+=(--buildDrafts --buildFuture)
|
||||
fi
|
||||
hugo "${args[@]}"
|
||||
Loading…
Reference in a new issue