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