🚀 GitHub Actions 工作流
持续集成 (CI)
- 触发条件: 推送到
main或develop分支,以及Pull Request - 流程: 代码检查 → 测试 → 构建 → Docker镜像构建推送
- 支持: 多平台构建(linux/amd64, linux/arm64)
自动发布 (Release)
- 触发条件: 推送版本标签 (
v*) - 流程: 构建多平台二进制文件 → 生成变更日志 → 创建GitHub Release
- 产物: Linux/macOS/Windows可执行文件 + Docker镜像
生产部署 (Deploy)
- 触发条件:
main分支代码更新 - 流程: SSH部署到生产服务器 → 健康检查 → Slack通知
- 特性: 自动备份 + 零停机部署
⚙️ 配置GitHub Secrets
在GitHub仓库设置中添加以下Secrets:
Docker相关
DOCKER_USERNAME=你的Docker Hub用户名
DOCKER_PASSWORD=你的Docker Hub密码
部署相关
DEPLOY_HOST=部署服务器IP
DEPLOY_USER=部署用户名
DEPLOY_KEY=SSH私钥
DEPLOY_PORT=SSH端口(默认22)
DEPLOY_URL=部署域名或IP
通知相关(可选)
SLACK_WEBHOOK=Slack通知webhook URL
JWT密钥(可选)
JWT_SECRET=你的JWT签名密钥
📦 一键部署脚本
提供自动化部署脚本,支持快速在Linux服务器上部署:
# 下载并运行部署脚本
curl -fsSL https://raw.githubusercontent.com/oldweipro/design-ai/main/deploy/install.sh | bash
# 或者手动部署
git clone https://github.com/oldweipro/design-ai.git
cd design-ai
chmod +x deploy/install.sh
./deploy/install.sh
🏗️ 手动发布流程
创建新版本发布:
# 1. 更新版本号并创建标签
git tag -a v1.2.0 -m "Release version 1.2.0"
# 2. 推送标签触发自动发布
git push origin v1.2.0
# 3. GitHub Actions 将自动:
# - 运行测试
# - 构建多平台二进制文件
# - 构建Docker镜像
# - 创建GitHub Release
🔧 本地开发环境
开发环境快速启动:
# 启动开发环境
docker-compose up -d
# 启动开发环境 + 监控
docker-compose --profile monitoring up -d
# 重新构建并启动
docker-compose up --build -d
# 查看日志
docker-compose logs -f design-ai
📊 监控和日志
生产环境支持可选的监控栈:
# 启动监控服务 (Grafana + Loki)
docker-compose --profile monitoring up -d
# 访问监控面板
# Grafana: http://localhost:3000 (admin/admin123)
🛠️ 部署架构
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ GitHub Repo │ │ GitHub Actions │ │ Production │
│ │ │ │ │ Server │
│ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ Code │─┼─→ │ │ CI/CD │─┼─→ │ │ Docker │ │
│ │ Changes │ │ │ │ Pipeline │ │ │ │ Containers │ │
│ └─────────────┘ │ │ └─────────────┘ │ │ └─────────────┘ │
│ │ │ │ │ │
│ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ Release │ │ │ │ Build & │ │ │ │ Nginx │ │
│ │ Tags │ │ │ │ Deploy │ │ │ │ Proxy │ │
│ └─────────────┘ │ │ └─────────────┘ │ │ └─────────────┘ │
└─────────────────┘ └─────────────────┘ └─────────────────┘

浙公网安备 33010602011771号