-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto-push-github.ps1
More file actions
118 lines (101 loc) · 5.31 KB
/
auto-push-github.ps1
File metadata and controls
118 lines (101 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env pwsh
# 自动推送到 GitHub 的完整脚本
Write-Host "🚀 AI Coder All-in-One - 自动推送到 GitHub" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host ""
# 步骤 1: 检查 Git 配置
Write-Host "📝 步骤 1/5: 检查 Git 配置..." -ForegroundColor Yellow
$gitUser = git config user.name
$gitEmail = git config user.email
if ([string]::IsNullOrWhiteSpace($gitUser) -or [string]::IsNullOrWhiteSpace($gitEmail)) {
Write-Host "⚠️ Git 用户信息未配置" -ForegroundColor Yellow
$userName = Read-Host "请输入您的 Git 用户名"
$userEmail = Read-Host "请输入您的 Git 邮箱"
git config --global user.name "$userName"
git config --global user.email "$userEmail"
Write-Host "✅ Git 配置已更新" -ForegroundColor Green
}
else {
Write-Host "✅ Git 用户: $gitUser ($gitEmail)" -ForegroundColor Green
}
Write-Host ""
# 步骤 2: 打开浏览器创建仓库
Write-Host "📝 步骤 2/5: 创建 GitHub 仓库..." -ForegroundColor Yellow
Write-Host "正在打开浏览器..." -ForegroundColor Cyan
Start-Process "https://github.com/new"
Write-Host ""
Write-Host "请在浏览器中完成以下操作:" -ForegroundColor Yellow
Write-Host "1. 登录 GitHub(如果尚未登录)" -ForegroundColor White
Write-Host "2. Repository name: AI_Coder_AllInOne" -ForegroundColor White
Write-Host "3. Description: 🚀 Unified Docker environment with VSCode Server, Claude Code, Vibe-Kanban, OpenCode/Sisyphus, and more AI coding tools" -ForegroundColor White
Write-Host "4. 选择 'Public' 公开仓库" -ForegroundColor White
Write-Host "5. 不要勾选 'Add a README file'" -ForegroundColor White
Write-Host "6. 不要勾选 'Add .gitignore'" -ForegroundColor White
Write-Host "7. 不要选择 'Choose a license'" -ForegroundColor White
Write-Host "8. 点击 'Create repository' 按钮" -ForegroundColor White
Write-Host ""
$confirm = Read-Host "完成后,请输入您的 GitHub 用户名"
if ([string]::IsNullOrWhiteSpace($confirm)) {
Write-Host "❌ 未输入用户名,脚本终止" -ForegroundColor Red
exit 1
}
$GITHUB_USERNAME = $confirm
Write-Host "✅ GitHub 用户名: $GITHUB_USERNAME" -ForegroundColor Green
Write-Host ""
# 步骤 3: 配置远程仓库
Write-Host "📝 步骤 3/5: 配置远程仓库..." -ForegroundColor Yellow
git remote remove origin 2>$null
git remote add origin "https://github.com/$GITHUB_USERNAME/AI_Coder_AllInOne.git"
Write-Host "✅ 远程仓库已配置: https://github.com/$GITHUB_USERNAME/AI_Coder_AllInOne.git" -ForegroundColor Green
Write-Host ""
# 步骤 4: 重命名分支
Write-Host "📝 步骤 4/5: 重命名分支为 main..." -ForegroundColor Yellow
git branch -M main
Write-Host "✅ 分支已重命名为 main" -ForegroundColor Green
Write-Host ""
# 步骤 5: 推送到 GitHub
Write-Host "📝 步骤 5/5: 推送代码到 GitHub..." -ForegroundColor Yellow
Write-Host "正在推送..." -ForegroundColor Cyan
Write-Host ""
git push -u origin main
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "🎉 成功推送到 GitHub!" -ForegroundColor Green
Write-Host ""
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host "📦 下一步操作:" -ForegroundColor Cyan
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host ""
Write-Host "1️⃣ 访问您的仓库:" -ForegroundColor Yellow
Write-Host " https://github.com/$GITHUB_USERNAME/AI_Coder_AllInOne" -ForegroundColor White
Write-Host ""
Write-Host "2️⃣ 启用 GitHub Actions:" -ForegroundColor Yellow
Write-Host " - 进入仓库 Settings → Actions → General" -ForegroundColor White
Write-Host " - 选择 'Read and write permissions'" -ForegroundColor White
Write-Host " - 点击 Save" -ForegroundColor White
Write-Host ""
Write-Host "3️⃣ 等待 Docker 镜像构建:" -ForegroundColor Yellow
Write-Host " - 查看 Actions 标签页" -ForegroundColor White
Write-Host " - 等待构建完成(约 10-15 分钟)" -ForegroundColor White
Write-Host ""
Write-Host "4️⃣ 更新 README 徽章:" -ForegroundColor Yellow
Write-Host " - 将 README.md 中的 YOUR_USERNAME 替换为 $GITHUB_USERNAME" -ForegroundColor White
Write-Host ""
Write-Host "🐳 构建完成后,镜像地址:" -ForegroundColor Cyan
Write-Host " ghcr.io/$GITHUB_USERNAME/ai_coder_allinone:latest" -ForegroundColor White
Write-Host ""
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
# 自动打开仓库页面
Start-Process "https://github.com/$GITHUB_USERNAME/AI_Coder_AllInOne"
}
else {
Write-Host ""
Write-Host "❌ 推送失败!" -ForegroundColor Red
Write-Host ""
Write-Host "可能的原因:" -ForegroundColor Yellow
Write-Host "1. 仓库尚未创建" -ForegroundColor White
Write-Host "2. 没有推送权限" -ForegroundColor White
Write-Host "3. 需要进行身份验证" -ForegroundColor White
Write-Host ""
Write-Host "请检查并重试" -ForegroundColor Yellow
}