diff --git a/scripts/deploy-gas.sh b/scripts/deploy-gas.sh new file mode 100644 index 0000000..99cafa0 --- /dev/null +++ b/scripts/deploy-gas.sh @@ -0,0 +1,39 @@ +#!/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" diff --git a/scripts/use-clasp.sh b/scripts/use-clasp.sh new file mode 100644 index 0000000..8409bfd --- /dev/null +++ b/scripts/use-clasp.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# use-clasp.sh — padanan Linux dari Use-Clasp.ps1 +# Aktifkan salah satu akun clasp (dev / bdn / mts) dengan swap file kredensial global. +# clasp hanya mengenal SATU login global (~/.clasprc.json), tanpa flag --local. +# Usage: ./use-clasp.sh +set -euo pipefail + +ACCOUNT="${1:-}" +case "$ACCOUNT" in + dev|bdn|mts) ;; + *) echo "Usage: $0 "; exit 1 ;; +esac + +PROFILE_DIR="$HOME/.clasp-accounts" +SRC="$PROFILE_DIR/$ACCOUNT.clasprc.json" +DST="$HOME/.clasprc.json" + +if [[ ! -f "$SRC" ]]; then + echo "Profil '$ACCOUNT' belum ada: $SRC" + exit 1 +fi + +cp -f "$SRC" "$DST" +chmod 600 "$DST" +echo "Akun clasp aktif: $ACCOUNT" + +if ! clasp show-authorized-user >/dev/null 2>&1; then + echo "Token profil '$ACCOUNT' tidak valid/kadaluarsa." + echo "Perbaiki: copy ulang $ACCOUNT.clasprc.json dari PC." + exit 1 +fi