mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-05 06:47:52 +01:00
Three hardcoded things in a public repo, each of which is someone else's
value baked into the source.
The box address had a literal fallback in five places: the CD workflow and
four operational shell scripts. A fallback literal guarantees the variable
is never exercised — if the variable were missing or wrong, every run would
still succeed against the baked-in address and nobody would find out until
the address changed. So:
- cd.yml takes the address from vars.OC_BOX, or root@ the HETZNER_IP
variable, and a new guard step fails the run with ::error:: when the
result is empty. The ssh-keyscan and ssh-config host now derive from
the host half of OC_BOX instead of repeating the literal, so the two
cannot drift apart silently.
- apply-migrations.sh, db/dump-live-schema.sh, db/gen-types.sh and
deploy-selfhost.sh use ${OC_BOX:?...}: they stop with one clear line
instead of reaching for a default. The two of them invoked by the
deploy script are already passed OC_BOX explicitly, and the workflow
sets it in the job env, so the configured path is unchanged.
An audit log was committed under logs/ in 2025-10 with 14 absolute paths
from a developer's machine. Nothing in the repo reads it (the only mentions
of the filename are inside the file itself). The `logs/` ignore rule was
added five days after the file, so it never applied to it — removed, and
the rule now says why, because ignoring a directory does not untrack what
is already inside it.
scripts/db/setup-db.ts signed in as a personal email address written into
the source. It now reads USER_EMAIL, matching the USER_PASSWORD it already
read, and exits with a clear message when unset.
Verified: bash -n on all four scripts and each one run with OC_BOX unset
(exit 1, clear message); the workflow parses and the guard step is in
place; pnpm run type-check:scripts green; prettier clean; the two unit
tests that read deploy-selfhost.sh pass.
Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Dump the self-host's LIVE public schema as { "table": ["col", ...] } JSON —
|
|
# the exact format audit-schema-drift.mjs consumes (scripts/db/live-schema.json).
|
|
#
|
|
# The static snapshot in the repo goes stale; the deploy pipeline calls this to
|
|
# get the box's ACTUAL schema (after applying pending migrations) and gate the
|
|
# release on a fresh drift check. Includes views (information_schema.columns
|
|
# covers them), so a missing real table is genuinely missing.
|
|
#
|
|
# Usage:
|
|
# scripts/db/dump-live-schema.sh > /tmp/live-schema.json
|
|
# OC_BOX=root@host scripts/db/dump-live-schema.sh > out.json
|
|
#
|
|
# Config: OC_BOX (required, user@host), OC_DB_CONTAINER (default supabase-db).
|
|
set -euo pipefail
|
|
|
|
OC_BOX="${OC_BOX:?set OC_BOX to the box SSH target, e.g. OC_BOX=root@<box-host>}"
|
|
OC_DB_CONTAINER="${OC_DB_CONTAINER:-supabase-db}"
|
|
SSH_OPTS=(-o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=12)
|
|
|
|
read -r -d '' SQL <<'EOSQL' || true
|
|
SELECT COALESCE(
|
|
json_object_agg(table_name, cols),
|
|
'{}'::json
|
|
)
|
|
FROM (
|
|
SELECT table_name, json_agg(column_name ORDER BY ordinal_position) AS cols
|
|
FROM information_schema.columns
|
|
WHERE table_schema = 'public'
|
|
GROUP BY table_name
|
|
) t;
|
|
EOSQL
|
|
|
|
ssh "${SSH_OPTS[@]}" "$OC_BOX" \
|
|
"docker exec -i $OC_DB_CONTAINER psql -U postgres -d postgres -tAc \"$(printf '%s' "$SQL" | tr '\n' ' ')\""
|