#!/usr/bin/env bash set -e # Get absolute path of this script's directory SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" ROOT_DIR="$SCRIPT_DIR/.." # Load config source "$ROOT_DIR/scripts/config.sh" git push origin main # SSH to target: pull, build, sync apps, restart ssh "$HOST" DEST="$DEST" APPS_DIR="$APPS_DIR" bash <<'SCRIPT' set -e cd "$DEST" && git checkout -- bun.lock && git pull origin main && bun install && rm -rf dist && bun run build echo "=> Syncing default apps..." for app_dir in "$DEST"/apps/*/; do app=$(basename "$app_dir") for version_dir in "$app_dir"*/; do [ -d "$version_dir" ] || continue version=$(basename "$version_dir") [ -f "$version_dir/package.json" ] || continue target="$APPS_DIR/$app/$version" mkdir -p "$target" cp -a "$version_dir"/. "$target"/ rm -f "$APPS_DIR/$app/current" echo " $app/$version" (cd "$target" && bun install --frozen-lockfile 2>/dev/null || bun install) done done sudo systemctl restart toes.service SCRIPT echo "=> Deployed to $HOST" echo "=> Visit $URL"