← back to Fentucci Naturals

scripts/cadence-golive.sh

38 lines

#!/usr/bin/env bash
# Daily go-live cadence tranche for the Fentucci Naturals (Tokiwa) line.
# Steve-approved 2026-07-27 ("arm the cadence"), gated by DTD verdict B (finish-
# then-close): trickle-activate 40/day rather than a bulk dump. go-live.py is
# idempotent — skips already-ACTIVE + golive-done.jsonl, drops the $0/yard variant,
# keeps the $4.25 sample, publishes to 12 channels (Google excluded). Exits 0 as a
# no-op once all 504 are live. Width already reconciled to 36"; Needs-Width dropped.
set -u
ROOT="$HOME/Projects/fentucci-naturals"
LOG="$ROOT/logs/cadence-golive.log"
mkdir -p "$ROOT/logs"
# grep-export, never `source` — an unquoted value in the secrets .env aborts set -a sourcing
SHOPIFY_ADMIN_TOKEN=$(grep '^SHOPIFY_ADMIN_TOKEN=' "$HOME/Projects/secrets-manager/.env" | cut -d= -f2- | tr -d '"')
export SHOPIFY_ADMIN_TOKEN
# TK-11471: go-live.py prefers the FULL-access token — the weight heal
# (inventoryItemUpdate) and inventory_levels writes need write_inventory,
# which the narrow SHOPIFY_ADMIN_TOKEN does not carry.
SHOPIFY_FULL_ACCESS_TOKEN=$(grep '^SHOPIFY_FULL_ACCESS_TOKEN=' "$HOME/Projects/secrets-manager/.env" | cut -d= -f2- | tr -d '"')
export SHOPIFY_FULL_ACCESS_TOKEN
# TK-11664 blind-spot fix: launchd runs this job with the minimal PATH
# (/usr/bin:/bin:/usr/sbin:/sbin) — no /opt/homebrew/bin — so the bare `psql`
# subprocess calls in go-live.py (settlement_map / pg_activate) died with
# FileNotFoundError BEFORE any product was processed. 18 tranches crashed this
# way (2026-07-28 .. 2026-09-15, "FileNotFoundError: ... 'psql'"), leaving 502/504
# products stranded in DRAFT outside this gated path (462 of them flipped ACTIVE
# through the rotation activator's `quotes` exemption instead, still carrying the
# $0.00 "Per Yard" placeholder go-live.py would have deleted). Same Osborne-class
# launchd-PATH bug already fixed in run-cadence-hourly.sh; mirrored verbatim here.
# Reversible: delete this line to restore the old behavior (and the crash).
export PATH="/opt/homebrew/bin:/opt/homebrew/opt/postgresql@14/bin:$PATH"
{
  echo "=== fentucci go-live tranche $(date '+%Y-%m-%d %H:%M:%S') ==="
  cd "$ROOT" && python3 scripts/go-live.py --apply --limit 40
  rc=$?
  echo "=== done $(date '+%Y-%m-%d %H:%M:%S') rc=$rc ==="
  exit $rc
} >> "$LOG" 2>&1