Files
gas-react-sheets/scripts/deploy-gas.sh
T
player a801f5f0e6
Lint / lint (push) Has been cancelled
deploy-gas.sh: validasi subdir + pesan error jelas
2026-10-01 08:41:15 +07:00

43 lines
1.2 KiB
Bash
Executable File

#!/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"
if [[ ! -d "$TARGET" ]]; then
echo "ERROR: subdir tidak ada: $TARGET"; exit 1
fi
fi
cd "$TARGET"
echo "--- clasp push ($TARGET, profil $PROFILE) ---"
clasp push
echo "DEPLOY OK: profil=$PROFILE target=$TARGET"