-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull-auto-deploy.ps1
More file actions
75 lines (61 loc) ยท 3.71 KB
/
full-auto-deploy.ps1
File metadata and controls
75 lines (61 loc) ยท 3.71 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
#!/usr/bin/env pwsh
# Full Auto Deploy - Build + Update + Test
param(
[string]$BuildId = "chd",
[string]$RG = "rg-gratech-comet",
[string]$App = "cometx-api",
[string]$ACR = "cometxreg"
)
Write-Host "`nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Cyan
Write-Host "๐ Full Auto Deploy" -ForegroundColor Green
Write-Host "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ`n" -ForegroundColor Cyan
# 1๏ธโฃ ู
ุฑุงูุจุฉ ุงูุจูุงุก
Write-Host "1๏ธโฃ ู
ุฑุงูุจุฉ ุงูุจูุงุก: $BuildId" -ForegroundColor Yellow
$maxAttempts = 30
$attempt = 0
$status = "Running"
while ($status -eq "Running" -and $attempt -lt $maxAttempts) {
Start-Sleep -Seconds 10
$attempt++
$status = az acr task show-run -r $ACR --run-id $BuildId --query "status" -o tsv 2>$null
Write-Progress -Activity "ุจูุงุก ุงูุตูุฑุฉ" -Status "$status" -PercentComplete ([int](($attempt/$maxAttempts)*100))
}
if ($status -eq "Succeeded") {
Write-Host "โ
ูุฌุญ ุงูุจูุงุก`n" -ForegroundColor Green
} else {
Write-Host "โ ูุดู ุงูุจูุงุก`n" -ForegroundColor Red
az acr task logs -r $ACR --run-id $BuildId | Select-String -Pattern "error|failed" -Context 1
exit 1
}
# 2๏ธโฃ ุฑุจุท ุงูุณุฌู ุจุงููููุฉ
Write-Host "2๏ธโฃ ุฑุจุท ุงูุณุฌู ุจุงููููุฉ ุงูู
ุฏุงุฑุฉ..." -ForegroundColor Yellow
az containerapp registry set -g $RG -n $App --server "${ACR}.azurecr.io" --identity system 2>$null
Write-Host "โ
ุชู
`n" -ForegroundColor Green
# 3๏ธโฃ ุชุฃููุฏ ุงูู
ููุฐ
Write-Host "3๏ธโฃ ุชุฃููุฏ ุงูู
ููุฐ 8080..." -ForegroundColor Yellow
az containerapp ingress update -g $RG -n $App --target-port 8080 --output none
Write-Host "โ
ุชู
`n" -ForegroundColor Green
# 4๏ธโฃ ุชุญุฏูุซ ุงูุตูุฑุฉ
Write-Host "4๏ธโฃ ุชุญุฏูุซ ุงูุตูุฑุฉ..." -ForegroundColor Yellow
az containerapp update -g $RG -n $App --image "${ACR}.azurecr.io/gratech-cometx:latest" --output none
Write-Host "โ
ุชู
`n" -ForegroundColor Green
# 5๏ธโฃ ุงูุชุธุงุฑ ุงูุชุญุฏูุซ
Write-Host "5๏ธโฃ ุงูุชุธุงุฑ ุงูุชุญุฏูุซ..." -ForegroundColor Yellow
Start-Sleep -Seconds 45
# 6๏ธโฃ ูุญุต ุงูุญุงูุฉ
Write-Host "6๏ธโฃ ูุญุต ุงูุญุงูุฉ..." -ForegroundColor Yellow
$revisions = az containerapp revision list -g $RG -n $App --query "[?properties.active].{name:name,health:properties.healthState,traffic:properties.trafficWeight}" -o json | ConvertFrom-Json
Write-Host "`n๐ ุงูู
ุฑุงุฌุนุงุช ุงููุดุทุฉ:" -ForegroundColor Cyan
foreach ($r in $revisions) {
$color = if ($r.health -eq "Healthy") { "Green" } else { "Red" }
Write-Host " $($r.name): $($r.health) (Traffic: $($r.traffic)%)" -ForegroundColor $color
}
# 7๏ธโฃ ุงุฎุชุจุงุฑ ุงูููุงุท
Write-Host "`n7๏ธโฃ ุงุฎุชุจุงุฑ ุงูููุงุท..." -ForegroundColor Yellow
Write-Host "`n๐ /healthz:" -ForegroundColor Cyan
curl.exe -I https://api.gratech.sa/healthz 2>&1 | Select-String "HTTP"
Write-Host "`n๐ /:" -ForegroundColor Cyan
curl.exe -I https://api.gratech.sa 2>&1 | Select-String "HTTP"
Write-Host "`nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Cyan
Write-Host "โ
ุงูุชู
ู!" -ForegroundColor Green
Write-Host "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ`n" -ForegroundColor Cyan