Skip to content

Commit 8faa597

Browse files
committed
site: inject generated snippets at deploy, pinned to the release tag
Clones metaobjects at its latest v0.x tag and runs its committed injector over www/, filling the data-snippet placeholders the previous commit put there. node, never bun: setup-node is this workflow's only toolchain step and ubuntu-latest has no bun, so a bun line would be command-not-found and — from before "Upload artifact" — would fail the whole deploy. The injector is dependency-free for that reason, so there is no install step either. The tag is filtered to the v0.x npm line on purpose. metaobjects carries two tag lines and an unfiltered `sort -V | tail -1` returns v7.20.12, a Maven-only cut whose tree has no examples/showcase — so an unfiltered pin breaks permanently, not once. It SKIPS with a ::warning:: when the pinned tag predates snippet injection rather than failing. Today's latest release, v0.24.4, is exactly that: no injector, no payload. Failing hard there would take down every deploy of this site — unrelated prose edits included — until the next metaobjects release. The skip can only trigger before that release and stops triggering after it. DO NOT PUSH until a metaobjects release ships the injector and the payload. Until then this repo's placeholders would deploy as empty code blocks.
1 parent d6a9f08 commit 8faa597

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ jobs:
4545
mkdir -p "$GITHUB_WORKSPACE/www/reference"
4646
cp -r /tmp/woo-docs/site/* "$GITHUB_WORKSPACE/www/reference/"
4747
48+
# Snippet injection: clone metaobjects at its latest npm RELEASE TAG — not main —
49+
# and inject its committed site-payload.json into this site's data-snippet
50+
# placeholders. Pinning to the tag matters: an unrelated site edit triggers a deploy,
51+
# and against main that deploy would publish unreleased snippets.
52+
#
53+
# `node`, never `bun`: setup-node above is this workflow's ONLY toolchain step and
54+
# ubuntu-latest carries no bun, so a bun line would be `command not found` and — from
55+
# here, before "Upload artifact" — would fail the entire deploy. The injector is plain
56+
# Node ESM with zero dependencies for exactly that reason, so there is no install step
57+
# (a root `bun install` would fetch 16 workspace packages to run a regex replace).
58+
- name: Inject generated snippets
59+
run: |
60+
set -euo pipefail
61+
git clone --filter=blob:none https://github.com/metaobjectsdev/metaobjects.git /tmp/mo
62+
cd /tmp/mo
63+
# The repo carries TWO tag lines: v0.x (npm lockstep) and v7.x (JVM). An
64+
# unfiltered `git tag -l 'v*' | sort -V | tail -1` returns v7.20.12 — a Maven-only
65+
# cut — and always will, because 7 sorts above 0. That tree has no
66+
# examples/showcase, so an unfiltered pin would break forever. Filter to the npm
67+
# line. (Never `git fetch --all`: it deletes local release tags.)
68+
TAG=$(git tag -l 'v0.*' | grep -E '^v0\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
69+
test -n "$TAG" || { echo "no v0.x release tag found"; exit 1; }
70+
git checkout --quiet "$TAG"
71+
# A release older than the injection program has neither the injector nor the
72+
# payload. Skip rather than fail: the pages still carry their placeholders, and a
73+
# hard failure here would take down the whole deploy — including unrelated prose
74+
# edits — for every push until the next release. Loud, and self-extinguishing.
75+
if [ ! -f scripts/site-inject-ci.mjs ] || [ ! -f examples/showcase/site-payload.json ]; then
76+
echo "::warning::metaobjects $TAG predates snippet injection — skipping. Code blocks will render EMPTY until the next release."
77+
exit 0
78+
fi
79+
echo "injecting snippets from metaobjects $TAG"
80+
node scripts/site-inject-ci.mjs --site "$GITHUB_WORKSPACE/www"
81+
4882
- name: Setup Pages
4983
uses: actions/configure-pages@v4
5084

0 commit comments

Comments
 (0)