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

ARCHIVE="/tmp/scm-slicing-$(date +%Y%m%d-%H%M%S).tar.gz"
DEST="devone:~/project/one/supply-chain-management"

echo "Creating archive..."
tar -czf "$ARCHIVE" --exclude='.git' --exclude='.gitignore' .

echo "Uploading to $DEST..."
scp "$ARCHIVE" "$DEST"

echo "Extracting on remote..."
ssh devone "cd ~/project/one/supply-chain-management && tar -xzf $(basename "$ARCHIVE") && rm $(basename "$ARCHIVE")"

rm "$ARCHIVE"
echo "Deploy complete."
