Add deploy.sh and update AGENTS.md with cross-machine workflow

This commit is contained in:
Warren
2026-05-20 08:40:01 +08:00
parent 61c7748d7e
commit 20deca3135
2 changed files with 45 additions and 0 deletions

View File

@@ -31,6 +31,18 @@
- API 設定存於 `localStorage('portal_config')`
- 401 回應會自動清除登入狀態並跳回 `/login`
## 跨機器推送與測試M4mini → M5Max128
Gitea 伺服器在 `m5max128.local:3000`。開發在 M4mini 進行,測試在 M5Max128
```bash
# 一鍵推送 + 部署 + 建置
./deploy.sh [commit message]
# 或手動
git commit -am "..." && git push
ssh accusys@m5max128.local "cd ~/momentry_portal && git pull && npm run build"
```
## 注意事項
- `tsconfig.json` 啟用 `strict` + `noUnusedLocals` + `noUnusedParameters` — 未使用的變數/參數會造成 `vue-tsc` 建置錯誤

33
deploy.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
REMOTE_USER="accusys"
REMOTE_HOST="m5max128.local"
REMOTE_DIR="~/momentry_portal"
if ! git diff --quiet --cached; then
echo ":: Unstaged changes detected. Stage or stash them first."
echo " git add -A && git stash"
exit 1
fi
if [ -n "$(git status --porcelain)" ]; then
echo ":: Uncommitted changes found."
if [ $# -ge 1 ]; then
git add -A && git commit -m "$*"
else
git add -A && git commit -m "deploy: $(date '+%Y-%m-%d %H:%M')"
fi
fi
echo ":: Pushing to Gitea..."
git push
echo ":: Deploying to ${REMOTE_HOST}..."
ssh "${REMOTE_USER}@${REMOTE_HOST}" \
"export PATH=\"\$HOME/.local/bin:\$PATH\" && eval \"\$(fnm env --use-on-cd)\" && \
cd ${REMOTE_DIR} && \
git pull && \
npm run build"
echo ":: Done"