-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeploymentUtilityMaster.ps1
85 lines (73 loc) · 2.7 KB
/
DeploymentUtilityMaster.ps1
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
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[Alias('a')]
[ValidateSet('build', 'push','buildAndPush','buildPushAndDeploy','deploy','deleteDeployment','getLogs', 'initData', 'info')]
[string]$action = "initData",
[Parameter(Mandatory=$false)]
[ValidateSet('all','Donation.QueueProcessor.Console','Donation.RestApi.Entrance','Donation.PersonSimulator.Console')]
[string]$app = "all"
)
<#
write-host "Clean System"
.\DeploymentUtilityAll.ps1 -a deleteDeployment -app all
.\DeploymentUtilityAll.ps1 -a initData
write-host "done"
write-host "Restart System"
.\DeploymentUtilityAll.ps1 -a deploy -app Donation.RestApi.Entrance
.\DeploymentUtilityAll.ps1 -a deploy -app Donation.PersonSimulator.Console
.\DeploymentUtilityAll.ps1 -a deploy -app Donation.QueueProcessor.Console
write-host "done - Running"
.\DeploymentUtilityAll.ps1 -a buildAndPush -app Donation.RestApi.Entrance
.\DeploymentUtilityAll.ps1 -a buildAndPush -app Donation.PersonSimulator.Console
write-host "done"
#>
if($null -eq (Get-Module Util)) {
Write-Host "PSScriptRoot: $PSScriptRoot"
Import-Module "$(if($PSScriptRoot -eq '') {'.'} else {$PSScriptRoot})\Util.psm1" -Force
}
function executeCommandInFolder($folder, $theAction) {
cd "$folder"
Write-Host ""
.\DeploymentUtility.ps1 -a $theAction
cd ..
}
cls
$scriptTitle = "Donation Automation Deployment Utility Master"
if($app -eq "all") {
$appFolders = @("Donation.RestApi.Entrance", "Donation.QueueProcessor.Console", "Donation.PersonSimulator.Console")
}
else {
$appFolders = @($app)
}
Write-Host "$scriptTitle" -ForegroundColor Yellow
Write-Host "Action: $action, App: $app" -ForegroundColor DarkYellow
switch($action) {
initData {
Set-Location "Donation.Monitor.Console"
dotnet run -deleteTable true
Set-Location ..
}
info {
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
build {
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
push {
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
buildAndPush {
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
deploy { # Deploy rest api service on 2 pod and loadBalancer
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
buildPushAndDeploy {
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
deleteDeployment { # Delete deployment of rest api service and loadBalancer
$appFolders | ForEach-Object -Process { executeCommandInFolder $_ $action }
}
}
Write-Host "`r`n$scriptTitle" -ForegroundColor Yellow