-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-github-push-advanced.ps1
More file actions
92 lines (80 loc) ยท 4.66 KB
/
fix-github-push-advanced.ps1
File metadata and controls
92 lines (80 loc) ยท 4.66 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
# ๐ ุณูุฑุจุช ุฅุนุฏุงุฏ Git Remote ูุงูุฏูุน - ูุณุฎุฉ ู
ุชูุฏู
ุฉ
param(
[string]$RepoOwner = "gratech-sa",
[string]$RepoName = "gratech-cometx",
[string]$Branch = "main"
)
$ErrorActionPreference = "Continue"
$RepoUrl = "https://github.com/$RepoOwner/$RepoName.git"
Write-Host "`nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Cyan
Write-Host "๐ ุณูุฑุจุช ุฅุนุฏุงุฏ GitHub Remote + ุฃูู ุฏูุน" -ForegroundColor Green
Write-Host "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ`n" -ForegroundColor Cyan
# 1๏ธโฃ ูุญุต GitHub CLI
Write-Host "๐ ุงูุชุญูู ู
ู GitHub CLI..." -ForegroundColor Yellow
$ghInstalled = Get-Command gh -ErrorAction SilentlyContinue
if (-not $ghInstalled) {
Write-Host "โ GitHub CLI ุบูุฑ ู
ุซุจุช. ุชุซุจูุชู ุงูุขู..." -ForegroundColor Red
Write-Host " ูู
ุจุชุดุบูู: winget install --id GitHub.cli" -ForegroundColor Cyan
exit 1
}
Write-Host "โ
GitHub CLI ู
ูุฌูุฏ`n" -ForegroundColor Green
# 2๏ธโฃ ูุญุต ูุฌูุฏ ุงูู
ุณุชูุฏุน
Write-Host "๐ ุงูุชุญูู ู
ู ูุฌูุฏ ุงูู
ุณุชูุฏุน $RepoOwner/$RepoName..." -ForegroundColor Yellow
$repoCheck = gh repo view "$RepoOwner/$RepoName" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "โ ๏ธ ุงูู
ุณุชูุฏุน ุบูุฑ ู
ูุฌูุฏุ ุฅูุดุงุคู ุงูุขู..." -ForegroundColor Yellow
gh repo create "$RepoOwner/$RepoName" --private --confirm
if ($LASTEXITCODE -eq 0) {
Write-Host "โ
ุชู
ุฅูุดุงุก ุงูู
ุณุชูุฏุน ุจูุฌุงุญ`n" -ForegroundColor Green
Start-Sleep -Seconds 3
} else {
Write-Host "โ ูุดู ุฅูุดุงุก ุงูู
ุณุชูุฏุน. ุชุญูู ู
ู ุงูุตูุงุญูุงุช." -ForegroundColor Red
exit 1
}
} else {
Write-Host "โ
ุงูู
ุณุชูุฏุน ู
ูุฌูุฏ`n" -ForegroundColor Green
}
# 3๏ธโฃ ุฅุฒุงูุฉ ุงูุฑูู
ูุช ุงููุฏูู
Write-Host "๐งน ุฅุฒุงูุฉ ุฃู ุฑูู
ูุช ูุฏูู
..." -ForegroundColor Yellow
git remote remove origin 2>$null
Write-Host "โ
ุชู
`n" -ForegroundColor Green
# 4๏ธโฃ ุฅุถุงูุฉ ุงูุฑูู
ูุช ุงูุฌุฏูุฏ
Write-Host "โ ุฅุถุงูุฉ ุงูุฑูู
ูุช: $RepoUrl" -ForegroundColor Green
git remote add origin $RepoUrl
Write-Host ""
# 5๏ธโฃ ุงูุชุญูู ู
ู ุงูุฑูู
ูุช
Write-Host "๐ ุงูุฑูู
ูุชุงุช ุงูุญุงููุฉ:" -ForegroundColor Magenta
git remote -v
Write-Host ""
# 6๏ธโฃ ุชุฌููุฒ ุงูููู
ุช
Write-Host "๐ฆ ุฅุถุงูุฉ ุงูู
ููุงุช..." -ForegroundColor Blue
git add .
Write-Host "๐พ ุฅูุดุงุก ููู
ุช..." -ForegroundColor Blue
$commitMsg = "chore: initial deployment setup with OIDC + Container Apps"
git commit -m $commitMsg 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Host "โ
ุชู
ุฅูุดุงุก ุงูููู
ุช`n" -ForegroundColor Green
} else {
Write-Host "โ ๏ธ ูุง ุชูุฌุฏ ุชุบููุฑุงุช ุฌุฏูุฏุฉ ููููู
ุช`n" -ForegroundColor Yellow
}
# 7๏ธโฃ ุงูุฏูุน
Write-Host "๐ ุฏูุน ุงูููุฏ ุฅูู $Branch..." -ForegroundColor Green
git push -u origin $Branch
if ($LASTEXITCODE -eq 0) {
Write-Host "`nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Green
Write-Host "๐ ูุฌุญ ุงูุฏูุน!" -ForegroundColor Green
Write-Host "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ`n" -ForegroundColor Green
Write-Host "๐ ุงูุฎุทูุงุช ุงูุชุงููุฉ:" -ForegroundColor Cyan
Write-Host " 1๏ธโฃ ุชุญูู ู
ู GitHub Actions: https://github.com/$RepoOwner/$RepoName/actions" -ForegroundColor White
Write-Host " 2๏ธโฃ ุฃุถู Secrets ูู GitHub Settings > Secrets:" -ForegroundColor White
Write-Host " โข AZURE_CLIENT_ID" -ForegroundColor Gray
Write-Host " โข AZURE_TENANT_ID" -ForegroundColor Gray
Write-Host " โข AZURE_SUBSCRIPTION_ID" -ForegroundColor Gray
Write-Host " 3๏ธโฃ ุงูุชุธุฑ ุงูุชู
ุงู CI/CD ูุงูุชุญูู ู
ู ุงููุดุฑ`n" -ForegroundColor White
} else {
Write-Host "`nโ ูุดู ุงูุฏูุน. ุงูุฃุฎุทุงุก ุฃุนูุงู." -ForegroundColor Red
Write-Host "๐ก ูุตุงุฆุญ:" -ForegroundColor Yellow
Write-Host " โข ุชุฃูุฏ ู
ู ุชุณุฌูู ุงูุฏุฎูู: gh auth login" -ForegroundColor Gray
Write-Host " โข ุชุฃูุฏ ู
ู ุงูุตูุงุญูุงุช ุนูู ุงูู
ุณุชูุฏุน" -ForegroundColor Gray
exit 1
}