From cac3ecd5de9d11c4fe1f5016f2ddcd1be3ca1bd3 Mon Sep 17 00:00:00 2001 From: chenhang Date: Fri, 12 Jun 2026 14:13:20 +0800 Subject: [PATCH] chore: add .env.example template and clean up deploy messages Introduce a tracked .env.example file documenting all required environment variables (app env, API/WebSocket base URLs, timeouts, Google/Facebook OAuth credentials, Cloudflare CDN zone/token). Update .gitignore to allow this file despite the blanket .env* ignore rule. Also simplify the push success/failure output in scripts/deploy/_deploy_lib.sh by removing verbose troubleshooting hints. --- .env.example | 31 +++++++++++++++++++++++++++++++ .gitignore | 1 + scripts/deploy/_deploy_lib.sh | 6 ++---- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..4ad91bef --- /dev/null +++ b/.env.example @@ -0,0 +1,31 @@ +# 当前环境: development | test | production +NEXT_PUBLIC_APP_ENV=development + +# 后端 API 基础 URL(按环境区分) +# development: http://172.16.48.49:3002 +# test: https://api.cozsweet.com +# production: https://api.cozsweet.com +NEXT_PUBLIC_API_BASE_URL=http://172.16.48.49:3002 + +# WebSocket URL(按环境区分,可选) +# development: ws://172.16.48.49:3002 +# test: wss://api.cozsweet.com +# production: wss://api.cozsweet.com +NEXT_PUBLIC_WS_BASE_URL=ws://172.16.48.49:3002 + +# API 超时时间(毫秒) +NEXT_PUBLIC_API_CONNECT_TIMEOUT=30000 +NEXT_PUBLIC_API_RECEIVE_TIMEOUT=60000 +NEXT_PUBLIC_API_SEND_TIMEOUT=30000 + +# Google OAuth 2.0 Client ID / Secret (Google Cloud Console → APIs & Services → Credentials) +AUTH_GOOGLE_ID= +AUTH_GOOGLE_SECRET= + +# Facebook App ID / Secret (Facebook Developers → 应用设置 → 基础) +AUTH_FACEBOOK_ID= +AUTH_FACEBOOK_SECRET= + +# Cloudflare CDN(test / production 部署后刷缓存用,scripts/deploy/_deploy_lib.sh 的 purge_cdn_cache 读这里) +CF_ZONE_ID= +CF_API_TOKEN= diff --git a/.gitignore b/.gitignore index 81173497..bfcd8638 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ yarn-error.log* # env files (can opt-in for committing if needed) .env* +!.env.example # deploy archives (scripts/deploy/_deploy_lib.sh 的 archive() 生成) archives/ diff --git a/scripts/deploy/_deploy_lib.sh b/scripts/deploy/_deploy_lib.sh index 769138d2..947a5a7b 100755 --- a/scripts/deploy/_deploy_lib.sh +++ b/scripts/deploy/_deploy_lib.sh @@ -34,13 +34,11 @@ push_to_server() { if [ $? -eq 0 ]; then echo "==========================================" - echo "推送成功!服务器端 post-receive hook 应已自动执行" + echo "推送成功!" echo "==========================================" else echo "==========================================" - echo "推送失败!常见原因:" - echo " 1. 本地分支与远端非 fast-forward(git pull --rebase 后再试)" - echo " 2. 服务器端 hook 报错(看 git push 输出)" + echo "推送失败!" echo "==========================================" return 1 fi