Files
012-kaopeilian/deploy/scripts/setup_git_strategy.sh
111 998211c483 feat: 初始化考培练系统项目
- 从服务器拉取完整代码
- 按框架规范整理项目结构
- 配置 Drone CI 测试环境部署
- 包含后端(FastAPI)、前端(Vue3)、管理端

技术栈: Vue3 + TypeScript + FastAPI + MySQL
2026-01-24 19:33:28 +08:00

60 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Git分支策略配置脚本
echo "=== 配置Git分支策略 ==="
cd /root/aiedu
# 1. 创建production分支如果不存在
if ! git branch | grep -q production; then
echo "创建production分支..."
git checkout -b production
git push origin production
echo "production分支已创建"
else
echo "production分支已存在"
fi
# 2. 切换到production分支
git checkout production
# 3. 更新webhook脚本监听production分支
echo "更新webhook配置..."
sed -i 's/refs\/heads\/main/refs\/heads\/production/g' /root/aiedu/scripts/webhook_handler.py
# 4. 重启webhook服务
systemctl restart kaopeilian-webhook.service
# 5. 创建.gitignore规则
echo "更新.gitignore..."
cat >> /root/aiedu/.gitignore << 'EOF'
# 生产环境配置文件(不提交)
kaopeilian-backend/.env.production
docker-compose.override.yml
# 服务器运行时文件
scripts/force_restart.sh
scripts/diagnose.sh
/var/log/kaopeilian_*.log
EOF
# 6. 提交配置变更
echo "提交配置变更到production分支..."
git add .gitignore scripts/webhook_handler.py
git commit -m "配置生产环境分支策略"
git push origin production
echo ""
echo "=== Git分支策略配置完成 ==="
echo ""
echo "使用说明:"
echo "1. 开发者在main分支开发"
echo "2. 生产环境使用production分支"
echo "3. 发布流程:"
echo " git checkout production"
echo " git merge main"
echo " git push origin production"
echo ""
echo "4. 服务器自动更新监听production分支"