feat: add deploy-dev.sh — scp + restart bypasses Syncthing lag
This commit is contained in:
parent
f2ef81fb7b
commit
759915eb01
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "posimai-root",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"deploy": "git push gitea main && git push github main",
|
||||
"deploy:dev": "bash scripts/deploy-dev.sh",
|
||||
"deploy:vps": "bash deploy-server.sh"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
# ============================================
|
||||
# posimai-dev — Ubuntu PC デプロイスクリプト
|
||||
# 使い方: bash scripts/deploy-dev.sh
|
||||
#
|
||||
# やること:
|
||||
# 1. git push (gitea + github)
|
||||
# 2. scp で変更ファイルを Ubuntu PC に直接転送
|
||||
# (Syncthing の同期待ちを回避)
|
||||
# 3. sudo systemctl restart posimai-dev
|
||||
# ============================================
|
||||
set -e
|
||||
|
||||
UBUNTU_PC="posimai-pc"
|
||||
REMOTE_DIR="~/posimai-project/posimai-dev"
|
||||
LOCAL_DIR="$(cd "$(dirname "$0")/../posimai-dev" && pwd)"
|
||||
|
||||
# ── カラー出力 ──────────────────────────────
|
||||
GREEN='\033[0;32m'; CYAN='\033[0;36m'; RED='\033[0;31m'; RESET='\033[0m'
|
||||
step(){ echo -e "\n${CYAN}→ $1${RESET}"; }
|
||||
ok() { echo -e " ${GREEN}$1${RESET}"; }
|
||||
err() { echo -e " ${RED}$1${RESET}"; exit 1; }
|
||||
|
||||
echo "========================================"
|
||||
echo " posimai-dev Deploy → Ubuntu PC"
|
||||
echo "========================================"
|
||||
|
||||
# ── Step 1: git push ────────────────────────
|
||||
step "Step 1: git push (gitea + github)"
|
||||
cd "$(dirname "$0")/.."
|
||||
git push gitea main && git push github main
|
||||
ok "push 完了"
|
||||
|
||||
# ── Step 2: scp 転送 ─────────────────────────
|
||||
step "Step 2: 変更ファイルを Ubuntu PC に直接転送"
|
||||
# posimai-dev/ 以下のファイルをすべて転送
|
||||
scp -r "$LOCAL_DIR/"* "${UBUNTU_PC}:${REMOTE_DIR}/"
|
||||
ok "転送完了"
|
||||
|
||||
# ── Step 3: サービス再起動 ──────────────────
|
||||
step "Step 3: posimai-dev サービス再起動"
|
||||
ssh "$UBUNTU_PC" "sudo systemctl restart posimai-dev"
|
||||
sleep 2
|
||||
STATUS=$(ssh "$UBUNTU_PC" "systemctl is-active posimai-dev")
|
||||
if [ "$STATUS" = "active" ]; then
|
||||
ok "再起動完了 (active)"
|
||||
else
|
||||
err "再起動失敗: status=$STATUS"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " Deploy 完了"
|
||||
echo "========================================"
|
||||
Loading…
Reference in New Issue