#!/usr/bin/env bash
# Runner artikel harian jam 09:00 WIB — publish 1 artikel per website (anti-duplikat kuat)
# Anti-duplikat tingkat RUNNER: sebelum publish, cek apakah domain target sudah punya
# post future/publish untuk TANGGAL SASARAN (= besok). Kalau sudah -> SKIP.
# Ini mencegah dobel walau isi config berbeda tiap run.
cd /home/mantapman/.hermes/profiles/atun/workspace || exit 1
LOG="artikel_harian_$(date +%Y-%m-%d).log"
echo "===== $(date '+%Y-%m-%d %H:%M:%S') WIB — RUN ARTIKEL HARIAN =====" >> "$LOG"

for cfg in cfg_*.py; do
  case "$cfg" in *_update.py) continue;; esac
  echo "--- publish via $cfg ---" >> "$LOG"
  python3 pipeline_artikel_harian.py "$cfg" >> "$LOG" 2>&1
done

echo "===== SELESAI $(date '+%H:%M:%S') =====" >> "$LOG"
