#!/usr/bin/env bash
set -e

# Get absolute path of this script’s directory
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$SCRIPT_DIR/.."

# Run deploy + config with absolute paths
source "$ROOT_DIR/scripts/config.sh"

# Make sure we're up-to-date
if [ -n "$(git status --porcelain)" ]; then
  echo "=> You have unsaved (git) changes"
  exit 1
fi

git push origin main

# Run remote install on the target
curl $URL/cmd/update