← back to Dw Marketing Reels

scripts/novasuede-cron-run.sh

33 lines

#!/usr/bin/env bash
# novasuede-cron-run.sh — one 3x/week campaign drop (ARMED): fan a distinct 3-colour post to
# each target account. Invoked by launchd com.steve.novasuede-color-post (Mon/Wed/Fri).
# Safe-by-design: build fails abort before any post; posting only fires with NS_POST=1.
set -euo pipefail
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
cd "$(dirname "$0")/.."                      # → dw-marketing-reels
set -a; [ -f .env ] && source .env; [ -f "$HOME/Projects/secrets-manager/.env" ] && source "$HOME/Projects/secrets-manager/.env"; set +a
mkdir -p "$HOME/.claude/logs"
LOG="$HOME/.claude/logs/novasuede-cron.log"
echo "[$(date -u +%FT%TZ)] novasuede drop START" >> "$LOG"

# TK-11086 (Steve 2026-09-01): DISARMED. Steve killed novasuede auto-posting to the DW network
# ("kill any posts of novasuede to designerwallcoverings websites. no overnight reels etc.").
# This wrapper is now a no-op posting-wise: NS_POST=0 = build-only, never live-posts. It also
# hard-exits before doing anything so a re-loaded launchd job cannot resurrect the drop.
echo "[$(date -u +%FT%TZ)] novasuede drop DISABLED by TK-11086 — no posting. exiting." >> "$LOG"
exit 0
# --- original armed line kept for one-line reversal (Steve re-arms by removing the exit 0 above
#     and restoring NS_POST=1) ---
# ARMED fan-post (novasuede skips until its creds land). NS_POST=1 = live.
NS_POST=0 node scripts/novasuede-run-all.mjs >> "$LOG" 2>&1 || { echo "[$(date -u +%FT%TZ)] run FAILED" >> "$LOG"; exit 1; }

# publish-result gate: fail loud (visible in launchd) if NO account posted this drop.
node -e '
const s=JSON.parse(require("fs").readFileSync("data/novasuede-post-state.json","utf8"));
const r=(s.last_run&&s.last_run.results)||[];
const posted=r.filter(x=>["posted","simulated","posted-unverified"].includes(x.status));
if(!posted.length){console.error("no account posted this drop");process.exit(1)}
console.log("posted to: "+posted.map(x=>x.account).join(", "));
' >> "$LOG" 2>&1 || { echo "[$(date -u +%FT%TZ)] PUBLISH CHECK FAILED — no account posted" >> "$LOG"; exit 1; }
echo "[$(date -u +%FT%TZ)] novasuede drop OK" >> "$LOG"