Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ===========================================
# 课伴 (KeBan) MVP-2 Alpha 环境变量模板
# 熵减 (Entropydecrease) 环境变量模板
# ===========================================
# 复制此文件为 .env 并填入实际值

Expand Down Expand Up @@ -54,10 +54,10 @@ AI_GATEWAY_PORT=8000
# --- 生产部署配置 ---

# CORS 允许的前端域名(多个用逗号分隔)
# CORS_ORIGINS=https://keban.app,https://www.keban.app
# CORS_ORIGINS=https://entropydecrease.com,https://www.entropydecrease.com

# 前端 API 基础 URL(生产环境设置为后端服务域名)
# VITE_API_BASE_URL=https://api.keban.app
# VITE_API_BASE_URL=https://api.entropydecrease.com

# 日志级别(DEBUG/INFO/WARNING/ERROR)
# LOG_LEVEL=INFO
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
51 changes: 40 additions & 11 deletions .github/workflows/deploy-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,56 @@ name: Deploy AI Gateway

on:
push:
branches: [master]
branches: [main]
paths: ['server/**']

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and push Docker image
run: |
cd server
docker build -t ai-gateway:${{ github.sha }} .
- name: Deploy to server

# 上传 server/ 源码到服务器(服务器非 git 仓库,代码由 CI 同步)
# 注意:rm 必须为 false —— 服务器上的 .env.production 为真实生产密钥,
# 不在仓库内(被 gitignore),删除目标目录会导致密钥永久丢失。
- name: Upload server sources
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: server/*
target: /opt/Entropydecrease
rm: false

- name: Rebuild and restart services
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /opt/keban
docker-compose pull
docker-compose up -d --force-recreate
sleep 10
curl -f http://localhost:8000/health || (docker-compose rollback && exit 1)
set -e
cd /opt/Entropydecrease/server

# .env.production 含生产密钥,必须显式传入,否则 DB_PASSWORD 等会被解析为空串
COMPOSE="docker compose -f docker-compose.prod.yml --env-file .env.production"

# 拉取第三方镜像(postgres/redis/nginx),自建服务由 --build 重新构建
$COMPOSE pull --ignore-buildable || true
$COMPOSE up -d --build --force-recreate

# 健康检查:失败时输出日志便于定位(docker compose 无 rollback 子命令,
# 回滚由 revert 提交重新触发部署完成)
sleep 15
if ! curl -fsS http://127.0.0.1:8000/health; then
echo "::error::ai-gateway 健康检查失败,最近日志:"
$COMPOSE logs --tail=60 ai-gateway
exit 1
fi
if ! curl -fsS http://127.0.0.1:8080/health; then
echo "::error::sync-service 健康检查失败,最近日志:"
$COMPOSE logs --tail=60 sync-service
exit 1
fi
echo "部署成功:ai-gateway 与 sync-service 健康检查通过"
8 changes: 4 additions & 4 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Website

on:
push:
branches: [master]
branches: [main]
paths: ['website/**']

jobs:
Expand All @@ -29,7 +29,7 @@ jobs:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: mkdir -p /opt/keban/website
script: mkdir -p /opt/Entropydecrease/website

- name: Upload static files to server
uses: appleboy/scp-action@v0.1.7
Expand All @@ -38,7 +38,7 @@ jobs:
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: website/out/*
target: /opt/keban/website
target: /opt/Entropydecrease/website
strip_components: 2
rm: true

Expand All @@ -52,7 +52,7 @@ jobs:
# scp 的 rm:true 会重建挂载目录导致 bind mount 失效,必须重启容器
docker restart entropy-decrease-nginx
sleep 5
curl -sf https://entropydecrease.com/ | grep -q "课伴" || exit 1
curl -sf https://entropydecrease.com/ | grep -q "熵减" || exit 1

- name: Notify IndexNow
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR Quality Check

on:
pull_request:
branches: [master]
branches: [main, dev]

jobs:
# ===========================================================================
Expand Down
110 changes: 55 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
name: Release Electron App

# 由 semantic-release 创建的 v* tag 触发:构建 Electron 安装包并附加到对应 Release
on:
push:
tags: ['v*']

# 上传构建产物到 GitHub Release 需要写权限
permissions:
contents: write

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: client/package-lock.json
- run: cd client && npm ci
- run: cd client && npm run lint
- run: cd client && npm run test -- --run

build:
needs: lint-test
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: client/package-lock.json
- run: cd client && npm ci
- run: cd client && npm run electron:build
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}
path: client/release/*.{exe,dmg,AppImage}

release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
- uses: softprops/action-gh-release@v2
with:
files: release-*/*
name: Release Electron App
# 由 semantic-release 创建的 v* tag 触发:构建 Electron 安装包并附加到对应 Release
on:
push:
tags: ['v*']
# 上传构建产物到 GitHub Release 需要写权限
permissions:
contents: write
jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: client/package-lock.json
- run: cd client && npm ci
- run: cd client && npm run lint
- run: cd client && npm run test -- --run
build:
needs: lint-test
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: client/package-lock.json
- run: cd client && npm ci
- run: cd client && npm run electron:build
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}
path: client/release/*.{exe,dmg,AppImage}
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
- uses: softprops/action-gh-release@v2
with:
files: release-*/*
2 changes: 1 addition & 1 deletion .github/workflows/version-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Version & Release
# 自动更新 package.json/package-lock.json、生成 CHANGELOG、创建 Git tag 与 GitHub Release。
on:
push:
branches: [master]
branches: [main]

# 同一分支串行执行,避免并发发布产生 tag/版本竞争
concurrency:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Thumbs.db
.env.local
.env.*.local
.env.production
.env.test

# Documentation (local only, not version controlled)
docs/
# Brainstorm scratch (personal notes)
brainstorm*.md
ui_brainstorm.md

Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit "$1"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"branches": [
"master"
"main"
],
"tagFormat": "v${version}",
"plugins": [
Expand Down
Loading
Loading