#!/usr/bin/env bash
set -euo pipefail

LOCK="/tmp/buenas-build.lock"
HOST_DIR="root@86.48.28.10:/opt/stack/landing-pages/buenas/"
SSH_KEY="/config/.ssh/contabo_key"

(
  flock -x 200
  echo "🔨 Build..."
  npm run build

  echo "🚀 Deploy → $HOST_DIR"
  scp -r -i "$SSH_KEY" -o StrictHostKeyChecking=no dist/. "$HOST_DIR"

  echo "✅ Buenas deployado em buenas.bayerl.cloud"
) 200>"$LOCK"
