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

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"