Commit Graph

28 Commits

Author SHA1 Message Date
admin 6014ac845d chore(deploy): containerize server deployment 2026-07-06 11:31:55 +08:00
admin 8cca42238e chore(git): remove pnpm environment variable setup from post-receive hook 2026-06-18 17:42:41 +08:00
admin 2b45237ea6 Revert "chore(deploy): run next with pm2"
This reverts commit 0bca7d4fa7.
2026-06-18 17:36:45 +08:00
admin 5d7ac1759e fix(deploy): include pnpm global bin path 2026-06-18 17:29:59 +08:00
admin 0bca7d4fa7 chore(deploy): run next with pm2 2026-06-18 16:33:29 +08:00
admin 428402d4b1 fix(deploy): detect service port with ss 2026-06-18 11:49:39 +08:00
admin b09795a7b8 fix(deploy): force stop existing next service 2026-06-18 11:35:26 +08:00
admin 70956559b8 chore(deploy): organize post receive hook globals 2026-06-17 18:43:26 +08:00
admin 15d322962e chore(deploy): choose start port by branch 2026-06-17 18:25:16 +08:00
admin 7f8e327582 chore(deploy): install dependencies before build 2026-06-17 17:40:01 +08:00
admin 8832552321 fix(githooks): write log timestamps in local time (was UTC + Z) 2026-06-16 18:24:27 +08:00
admin 436a0addcc fix(githooks): pin absolute GIT_DIR and unset GIT_WORK_TREE in post-receive 2026-06-16 16:31:35 +08:00
admin db350aae44 fix(githooks): use absolute-git-dir to find worktree in post-receive
`git rev-parse --show-toplevel` in hook context (cwd=GIT_DIR, GIT_DIR
set) returns the .git path itself without erroring, so the previous
`|| echo $PWD` fallback never triggered and the script silently
cd'd into .git/.

Use `git rev-parse --absolute-git-dir` to reliably get the absolute
git-dir, then its parent is the worktree root. This works in both
interactive shells and hook context.
2026-06-16 15:58:38 +08:00
admin 697dce64b1 chore: remove bold markers from Chinese characters in post-receive hook comments 2026-06-16 15:39:00 +08:00
admin 7506dcae3a chore(githooks): sync worktree to new HEAD in post-receive hook
The post-receive hook now performs a `git reset --hard HEAD` after each push
to ensure the working tree reflects the newly received commits. This is needed
when the server's `receive.denyCurrentBranch` is set to `false`, in which case
Git no longer auto-updates the working tree and downstream build steps would
otherwise run against stale code.
2026-06-16 13:24:37 +08:00
admin 664ff67ee9 chore(githooks): simplify post-receive hook and overwrite server log
Simplify the repo toplevel detection logic and remove verbose comments from the post-receive hook. Switch next-server.log from append mode to overwrite mode so each deploy starts with a fresh log file.
2026-06-15 18:44:35 +08:00
admin 1f3980d461 chore(chat): refactor chat init into separate quota and history actors
Split `chatInitActor` into `loadQuotaActor` (guest quota fetch) and `loadHistoryActor` (local → network → save sync), and add `quotaLoaded` / `historyLoaded` state flags so the UI can display loading status during the new local-first history hydration flow. Also drop the now-unused `ChatInit` event and pipe Next.js stdout/stderr to a persistent log file in the post-receive hook for easier troubleshooting.
2026-06-15 16:21:40 +08:00
admin 4a86e95ecf fix(githooks): restore cd-to-repo-top before NVM load
Without cd, git rev-parse --show-toplevel fails inside .git/
with 'must be run in a work tree', causing init_log_file to
write to /logs/post-receive.log (root path), and copy_env_by_branch
to fail with 'cannot stat env-example/...'.
2026-06-15 14:18:58 +08:00
admin cc75bed133 chore(githooks): simplify post-receive hook
Remove the repo top-level navigation logic and its accompanying
explanatory comments from the post-receive hook. The previous code
used `git rev-parse --absolute-git-dir` and `dirname` to determine
and `cd` into the repository's top-level directory, which is no
longer needed. The hook now starts directly with the nvm setup,
making the script leaner and easier to maintain.
2026-06-15 14:10:26 +08:00
admin 3b1ab0fc1b fix(githooks): use git rev-parse --absolute-git-dir for repo root
The $0-based dirname trick didn't work because git invokes
hooks with just the basename (e.g., 'post-receive'), not the
absolute path. Use 'git rev-parse --absolute-git-dir' instead,
which works even when CWD is inside .git/.
2026-06-15 13:07:16 +08:00
admin d3e134d247 fix(githooks): use simple NVM loading (same as .bashrc)
Replace complex pnpm-finding fallback with the same NVM loading
syntax used in ~/.bashrc. Removes the multiple candidate-path
fallback loop in favor of a clean shell snippet.
2026-06-15 13:02:46 +08:00
admin b7e048ed87 fix(githooks): derive repo top from $0 path (not --show-toplevel)
git-receive-pack may invoke hook with CWD inside .git/,
where 'git rev-parse --show-toplevel' errors with
'must be run in a work tree'. Use $(dirname $0) instead.
2026-06-15 11:51:49 +08:00
admin 558b3a32af fix(githooks): cd to repo top + load pnpm into PATH
- cd to repo toplevel first (defensive: git-receive-pack CWD may differ)
- source nvm or directly find pnpm binary if not in PATH
- prepend pnpm's dir to PATH so build/start work

Root cause: post-receive hook was not being triggered on push.
With core.hooksPath=.githooks (relative), git-receive-pack
resolved the path incorrectly. Also pnpm wasn't in PATH during
non-interactive shell invocation.
2026-06-15 11:48:49 +08:00
admin 9c1622c6bd test: add marker to hook 2026-06-15 11:32:24 +08:00
admin 83fdd73923 refactor(githooks): restructure post-receive hook into modular functions
Refactor the post-receive deployment hook from a linear script into
discrete functions (init_log_file, write_metadata_header,
copy_env_by_branch, run_build, stop_existing_next, launch_next) for
better readability, maintainability, and error isolation.

Key changes:
- Remove `set -e` so deploy errors don't block git push; each step
  handles its own failures (missing env, build failure
2026-06-12 19:08:25 +08:00
admin f72d1ce94f ci(deploy): branch-aware env copy and restore start output silencing
- Select env template per branch: main → .env.production, test/dev → .env.local
- Skip env copy on unknown branches with warning log
- Revert pnpm run start output to /dev/null (debugging complete)
- Reorder LOG_FILE definition before env-copy block so case branches can log
2026-06-12 18:53:30 +08:00
admin c90d2a5139 chore(env): add AUTH_SECRET for next-auth across environments
- Add per-environment AUTH_SECRET (dev/test/prod) for next-auth v4 JWT signing
- Temporarily redirect next start stdout/stderr to LOG_FILE in post-receive hook for server error debugging
2026-06-12 18:42:43 +08:00
admin 546e5f4b3d chore(githooks): rename hooks dir to .githooks and stop old next processes
Move repository-managed git hooks from `git_hooks/` to `.githooks/` to follow the conventional hidden-directory naming, and add a graceful shutdown step in `post-receive` that terminates any running `next start` / `next-server` processes (SIGTERM → wait 2s → SIGKILL → wait 1s) before relaunching, avoiding EADDRINUSE port conflicts so the freshly built code actually takes effect. README updated to reference the new path.
2026-06-12 18:24:08 +08:00