mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 04:57:00 +01:00
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
67 lines
3.0 KiB
Bash
Executable File
67 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# check-deploy-ref.sh — the off-main gate for hand-run deploys.
|
|
#
|
|
# INVARIANT: production may only ever run a commit contained in origin/main.
|
|
#
|
|
# deploy-hetzner.sh already guards against HEAD moving DURING a build (--ref).
|
|
# That does nothing about the bigger hazard: deploying a commit that was never
|
|
# on main at all. A worktree sitting on a feature branch carries unreviewed
|
|
# commits AND is missing everything merged since it branched, so shipping it
|
|
# does two bad things at once — publishes unreviewed code and silently ROLLS
|
|
# BACK main.
|
|
#
|
|
# Not hypothetical; it has happened twice. The second time (2026-08-14) two
|
|
# local deploys ran minutes apart from a stale branch, rotating the correct CI
|
|
# build out through app.prev and reverting three merged PRs. Prod then served a
|
|
# Loki with no approval-queue tool while main had shipped it hours earlier — and
|
|
# the symptom was indistinguishable from an application bug, so it was chased
|
|
# through the app for an hour. Ancestry is the invariant, so it is checked, not
|
|
# remembered.
|
|
#
|
|
# Usage: bash scripts/ci/check-deploy-ref.sh <repo-dir> [ref]
|
|
# Exit: 0 = safe to deploy (or gate legitimately skipped), 1 = refuse.
|
|
# Override: LOKI_DEPLOY_ALLOW_OFF_MAIN=1 (deliberate, must be typed).
|
|
|
|
set -euo pipefail
|
|
|
|
REPO="${1:?usage: check-deploy-ref.sh <repo-dir> [ref]}"
|
|
REF="${2:-HEAD}"
|
|
|
|
if [ -n "${LOKI_DEPLOY_ALLOW_OFF_MAIN:-}" ]; then
|
|
echo " ⚠ off-main gate OVERRIDDEN by LOKI_DEPLOY_ALLOW_OFF_MAIN"
|
|
exit 0
|
|
fi
|
|
|
|
SHIP_SHA="$(git -C "$REPO" rev-parse --verify --quiet "${REF}^{commit}" || echo "")"
|
|
if [ -z "$SHIP_SHA" ]; then
|
|
echo "✗ deploy REFUSED — '${REF}' does not resolve to a commit in ${REPO}." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Refresh origin/main so a locally-stale ref cannot produce a false refusal.
|
|
# Never fatal: an offline laptop should still be gated on what it knows.
|
|
git -C "$REPO" fetch --quiet origin main 2>/dev/null || true
|
|
|
|
MAIN_REF="$(git -C "$REPO" rev-parse --verify --quiet origin/main || echo "")"
|
|
if [ -z "$MAIN_REF" ]; then
|
|
# Shallow/hosted CI checkouts have no origin/main ref. Warn rather than block:
|
|
# the hosted deploy path builds main by construction, and hard-failing here
|
|
# would break the very pipeline this gate exists to protect.
|
|
echo " ⚠ off-main gate skipped — origin/main not resolvable in this checkout"
|
|
exit 0
|
|
fi
|
|
|
|
if git -C "$REPO" merge-base --is-ancestor "$SHIP_SHA" "$MAIN_REF"; then
|
|
exit 0
|
|
fi
|
|
|
|
BRANCH="$(git -C "$REPO" rev-parse --abbrev-ref HEAD 2>/dev/null || echo detached)"
|
|
AHEAD="$(git -C "$REPO" rev-list --count "${MAIN_REF}..${SHIP_SHA}" 2>/dev/null || echo '?')"
|
|
BEHIND="$(git -C "$REPO" rev-list --count "${SHIP_SHA}..${MAIN_REF}" 2>/dev/null || echo '?')"
|
|
|
|
echo "✗ deploy REFUSED — ${SHIP_SHA:0:12} (${BRANCH}) is not contained in origin/main." >&2
|
|
echo " ${AHEAD} commit(s) here are unreviewed; ${BEHIND} commit(s) on main would be ROLLED BACK." >&2
|
|
echo " Ship through the pipeline instead: open a PR, let it merge, Deploy runs on main." >&2
|
|
echo " To override deliberately: LOKI_DEPLOY_ALLOW_OFF_MAIN=1 bash scripts/deploy-hetzner.sh" >&2
|
|
exit 1
|