Files
gas-react-sheets/scripts/deploy-gas.sh
T
2026-10-01 08:30:27 +07:00

40 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# deploy-gas.sh — dipanggil n8n via SSH untuk deploy satu target GAS.
# Usage: ./deploy-gas.sh <dev|bdn|mts> [project-subdir]
# profile dev/bdn/mts = akun clasp + file .clasp.<profile>.json di repo root
# project-subdir = opsional, mis. projects/mts-alamin-2025 (punya .clasp.json sendiri)
set -euo pipefail
PROFILE="${1:-}"
SUBDIR="${2:-}"
REPO="$HOME/gas-react-sheets"
case "$PROFILE" in
dev|bdn|mts) ;;
*) echo "Usage: $0 <dev|bdn|mts> [project-subdir]"; exit 1 ;;
esac
"$(dirname "$0")/use-clasp.sh" "$PROFILE"
# Pilih file .clasp.json sesuai profil bila ada (pola repo ini: .clasp.<profil>.json)
if [[ -f "$REPO/.clasp.$PROFILE.json" ]]; then
cp -f "$REPO/.clasp.$PROFILE.json" "$REPO/.clasp.json"
fi
cd "$REPO"
echo "--- git pull ---"
git pull --ff-only || echo "WARN: bukan git repo / pull gagal, lanjut dengan tree existing"
echo "--- yarn install ---"
yarn install --frozen-lockfile
echo "--- build ---"
yarn build
TARGET="$REPO"
if [[ -n "$SUBDIR" ]]; then
TARGET="$REPO/$SUBDIR"
fi
cd "$TARGET"
echo "--- clasp push ($TARGET, profil $PROFILE) ---"
clasp push
echo "DEPLOY OK: profil=$PROFILE target=$TARGET"