Runner scripts: use-clasp.sh + deploy-gas.sh (padanan Linux Use-Clasp.ps1)
Lint / lint (push) Has been cancelled

This commit is contained in:
player
2026-10-01 08:30:27 +07:00
parent 8e0b928a80
commit 8d75326bb6
2 changed files with 70 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/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"
+31
View File
@@ -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 <dev|bdn|mts>
set -euo pipefail
ACCOUNT="${1:-}"
case "$ACCOUNT" in
dev|bdn|mts) ;;
*) echo "Usage: $0 <dev|bdn|mts>"; 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