mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
Two docs sites, from one Docs workflow (`.github/workflows/docs.yml`): - **devvm.dev** shows the latest release's docs. The `release` job builds a tag's `docs/` and the `deploy` job deploys it to GitHub Pages (`github-pages` environment), on a published release that isn't a prerelease, and on a `workflow_dispatch` with `site=devvm.dev` and `ref` (a release tag; empty means the latest release, from `gh release view`). The tag is checked against `^v[0-9]+\.[0-9]+\.[0-9]+$` through `env:` before it's used, and checked out as `refs/tags/<tag>`. Pushes to main no longer deploy devvm.dev. - **next.devvm.dev** shows main's docs. On pushes to main that touch the docs (the same paths anchor), or a dispatch with `site=next.devvm.dev`, `check` lints and builds, then `next` builds with `hugo -s docs --minify --config hugo.yaml,next.yaml`, checks out devvmhq/docs-next with `DOCS_NEXT_DEPLOY_KEY` (environment `docs-next`, only after the build), replaces everything but README.md, and commits `Build from devvm <short sha>` as github-actions[bot], skipping an unchanged build. Its concurrency group keeps pushes from racing. - `docs/next.yaml` sets `baseURL: https://next.devvm.dev/`, Hextra's `params.banner` (a note that links devvm.dev), and `noindex` both as a site param and through `cascade`, so Hextra's head writes `noindex, nofollow` on every page. `docs/layouts/robots.txt` adds `Disallow: /` when the site's `noindex` is set. The build stays in Hugo's production environment, so Hextra's minified, fingerprinted assets are the same as devvm.dev's. - PRs get the same lint and build as before, and nothing runs with an environment or a secret on `pull_request`. Permissions: `contents: read` at the top; only `deploy` has `pages: write` and `id-token: write`. The publishing jobs set `cache: false` on mise-action (zizmor's cache-poisoning, now that the workflow publishes on `release`), and so does `check`. - Docs: Contributing's Maintaining has a new section, The docs sites (what deploys each, the hand redeploy, the key and environments, Cloudflare Pages serving devvmhq/docs-next); Contributing's two mentions of the deploy point at it; Upgrading's Trying a prerelease links next.devvm.dev. Co-authored-by: Claude Opus 5.5 <[email protected]>
185 lines
7.0 KiB
YAML
185 lines
7.0 KiB
YAML
name: Docs
|
|
|
|
# Two sites. devvm.dev shows the latest release's docs: a published release that isn't a
|
|
# prerelease deploys its tag's docs to GitHub Pages, and so does a dispatch, with any release's
|
|
# tag. next.devvm.dev shows main's: each push to main that changes the docs builds them with
|
|
# docs/next.yaml and commits the site to devvmhq/docs-next, which Cloudflare Pages serves.
|
|
# Pull requests touching the docs get their lints and a build, and nothing else.
|
|
# The site is built from docs/ alone (the CLI reference included, which a help change commits
|
|
# there), and CI's lint runs the docs checks on every code change, so other pushes skip this.
|
|
# A release event runs this file as its tag has it.
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths: &docs-paths
|
|
- "docs/**"
|
|
- "**.md"
|
|
- ".vale.ini"
|
|
- ".vale/**"
|
|
- ".markdownlint-cli2.yaml"
|
|
- ".github/workflows/docs.yml"
|
|
pull_request:
|
|
paths: *docs-paths
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
site:
|
|
description: The site to deploy
|
|
type: choice
|
|
options: [devvm.dev, next.devvm.dev]
|
|
default: devvm.dev
|
|
ref:
|
|
description: "devvm.dev only: the release tag whose docs it shows, such as v0.1.0 (empty: the latest release)"
|
|
type: string
|
|
required: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# main's docs, or a pull request's: the lints and a build.
|
|
check:
|
|
if: >-
|
|
github.event_name == 'pull_request' || github.event_name == 'push' ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.site == 'next.devvm.dev')
|
|
runs-on: ubuntu-latest
|
|
# A pull request's newer run replaces its last.
|
|
concurrency:
|
|
group: docs-check-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
env:
|
|
# Only the docs' tools, not every tool in mise.toml.
|
|
MISE_TASK_RUN_AUTO_INSTALL: "false"
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# Full history, for each page's last updated date.
|
|
fetch-depth: 0
|
|
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
|
|
with:
|
|
version: 2026.10.18
|
|
install_args: go hugo-extended node markdownlint-cli2 vale lychee
|
|
# The workflow publishes, so no job in it reads a cache another run could have written.
|
|
cache: false
|
|
- run: mise run lint:docs
|
|
# The site's address is baseURL in docs/hugo.yaml.
|
|
- run: hugo -s docs --minify
|
|
|
|
# next.devvm.dev: main's docs, committed to devvmhq/docs-next.
|
|
next:
|
|
if: >-
|
|
github.ref == 'refs/heads/main' &&
|
|
(github.event_name == 'push' ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.site == 'next.devvm.dev'))
|
|
needs: check
|
|
runs-on: ubuntu-latest
|
|
# One push at a time; a newer run waiting replaces an older one.
|
|
concurrency:
|
|
group: docs-next
|
|
cancel-in-progress: false
|
|
# The environment holds the deploy key, and only main can use it.
|
|
environment:
|
|
name: docs-next
|
|
url: https://next.devvm.dev/
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 0
|
|
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
|
|
with:
|
|
version: 2026.10.18
|
|
install_args: go hugo-extended
|
|
# What's published is built from no cache.
|
|
cache: false
|
|
# docs/next.yaml over docs/hugo.yaml: next.devvm.dev's address, the banner and noindex.
|
|
- run: hugo -s docs --minify --config hugo.yaml,next.yaml -d "$RUNNER_TEMP/next"
|
|
# The key is checked out only after the build, which never sees it.
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
repository: devvmhq/docs-next
|
|
ref: main
|
|
path: docs-next
|
|
ssh-key: ${{ secrets.DOCS_NEXT_DEPLOY_KEY }}
|
|
# The push below needs the key; this checkout is the only thing that uses it.
|
|
persist-credentials: true # zizmor: ignore[artipacked] -- the push needs the deploy key, and nothing is uploaded
|
|
- name: Publish
|
|
working-directory: docs-next
|
|
run: |
|
|
# Everything but README.md is the site's.
|
|
find . -mindepth 1 -maxdepth 1 ! -name .git ! -name README.md -exec rm -rf {} +
|
|
cp -R "$RUNNER_TEMP/next/." .
|
|
git add -A
|
|
if git diff --cached --quiet; then
|
|
echo "next.devvm.dev is already this build."
|
|
exit 0
|
|
fi
|
|
git -c user.name="github-actions[bot]" \
|
|
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
|
commit -q -m "Build from devvm ${GITHUB_SHA::7}"
|
|
git push origin HEAD:main
|
|
|
|
# devvm.dev: a release's docs, built from its tag.
|
|
release:
|
|
if: >-
|
|
(github.event_name == 'release' && !github.event.release.prerelease) ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.site == 'devvm.dev')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- id: tag
|
|
name: The release's tag
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
EVENT: ${{ github.event_name }}
|
|
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
INPUT_REF: ${{ inputs.ref }}
|
|
run: |
|
|
if [ "$EVENT" = release ]; then
|
|
tag=$RELEASE_TAG
|
|
elif [ -n "$INPUT_REF" ]; then
|
|
tag=$INPUT_REF
|
|
else
|
|
tag=$(gh release view --repo devvmhq/devvm --json tagName --jq .tagName)
|
|
fi
|
|
if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
echo "::error::A release tag is vX.Y.Z, such as v0.1.0; this is $tag."
|
|
exit 1
|
|
fi
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: refs/tags/${{ steps.tag.outputs.tag }}
|
|
persist-credentials: false
|
|
# Full history, for each page's last updated date.
|
|
fetch-depth: 0
|
|
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
|
|
with:
|
|
version: 2026.10.18
|
|
install_args: go hugo-extended
|
|
# What's published is built from no cache.
|
|
cache: false
|
|
# The tag's docs/hugo.yaml, whose baseURL is devvm.dev.
|
|
- run: hugo -s docs --minify
|
|
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
|
with:
|
|
path: docs/public
|
|
|
|
deploy:
|
|
needs: release
|
|
runs-on: ubuntu-latest
|
|
# Deploys queue one after another.
|
|
concurrency:
|
|
group: docs-pages
|
|
cancel-in-progress: false
|
|
permissions:
|
|
pages: write # to deploy the site
|
|
id-token: write # to prove the deployment comes from this workflow
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- id: deployment
|
|
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
|