#!/usr/bin/env bash # deploy-gas.sh — dipanggil n8n via SSH untuk deploy satu target GAS. # Usage: ./deploy-gas.sh [project-subdir] # profile dev/bdn/mts = akun clasp + file .clasp..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 [project-subdir]"; exit 1 ;; esac "$(dirname "$0")/use-clasp.sh" "$PROFILE" # Pilih file .clasp.json sesuai profil bila ada (pola repo ini: .clasp..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"