-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathProvisionEpiEnvironment.ps1
More file actions
85 lines (74 loc) · 3.06 KB
/
Copy pathProvisionEpiEnvironment.ps1
File metadata and controls
85 lines (74 loc) · 3.06 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
#---------------------------------------------------------------------------
# Name: ProvisionOptiEnvironment.ps1
#
# Summary: This script will provision a brand new Opti
# environment without pushing new code. (Usually
# the Preproduction and Production environments)
#
# Last Updated: 5/15/2024
#
# Author: Eric Markson - eric@optimizelyvisuals.dev | eric@ericmarkson.com | https://optimizelyvisuals.dev/
#
# License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
#---------------------------------------------------------------------------
#Setting up Parameters
#Setting each Paramater has Mandatory, as they are not optional
#Validating each paramarer for being Null or Empty, using the built in Validator
param
(
[Parameter(Position=0, Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$ClientKey,
[Parameter(Position=1, Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$ClientSecret,
[Parameter(Position=2, Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$ProjectID,
[Parameter(Position=3)]
[ValidateNotNullOrEmpty()]
[string]$ArtifactPath,
[Parameter(Position=4)]
[ValidateScript({
If ($_ -match "^(Integration|Preproduction|Production|ADE\d+)$") {
$True
}
else {
Throw "Valid environment names are Integration, Preproduction, Production, or ADE#"
}})]
[string]$TargetEnvironment,
[Parameter(Position=5)]
[ValidateSet($true, $false, 0, 1)]
[bool]$NetCore = 1
)
#Checking that the required params exist and are not white space
if([string]::IsNullOrWhiteSpace($ClientKey)){
throw "A Client Key is needed. Please supply one."
}
if([string]::IsNullOrWhiteSpace($ClientSecret)){
throw "A Client Secret Key is needed. Please supply one."
}
if([string]::IsNullOrWhiteSpace($ProjectID)){
throw "A Project ID GUID is needed. Please supply one."
}
if([string]::IsNullOrWhiteSpace($TargetEnvironment)){
throw "A target deployment environment is needed. Please supply one."
}
if([string]::IsNullOrWhiteSpace($ArtifactPath) -and $NetCore -eq $true){
$ArtifactPath = "./Packages/ProvisionEnvironmentCore.cms.app.1.nupkg"
}
elseif([string]::IsNullOrWhiteSpace($ArtifactPath) -and $NetCore -eq $false){
$ArtifactPath = "./Packages/ProvisionEnvironment.cms.app.1.nupkg"
}
Write-Warning "If this environment has code on it, this can be destructive."
$confirmation = Read-Host "Do you want to proceed? 'y' to continue. 'n' to quit"
if ($confirmation.ToLower() -ne 'y') {
exit
}
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
Push-Location $dir
.\UploadEpiPackage.ps1 -ClientKey $ClientKey -ClientSecret $ClientSecret -ProjectID $ProjectID -ArtifactPath $ArtifactPath
.\DeployToEnvironment.ps1 -ClientKey $ClientKey -ClientSecret $ClientSecret -ProjectID $ProjectID -ArtifactPath $ArtifactPath -TargetEnvironment $TargetEnvironment -UseMaintenancePage $false
.\CompleteOrResetDeployment.ps1 -ClientKey $ClientKey -ClientSecret $ClientSecret -ProjectID $ProjectID -TargetEnvironment $TargetEnvironment -Action "Reset"
Pop-Location