-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-prod.ps1
54 lines (43 loc) · 2.26 KB
/
deploy-prod.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
## Version 1.1
## Author Theo Xavier
## Edited 3/4/2019
$currentWebAppDirectory = "//lfkqbwtweb02/c$/inetpub/wwwroot/docunex/"
$backupWebAppDirectory = "//lfkqbwtweb02/c$/inetpub/wwwroot/backup/docunex-backup/"
$temporaryDeployFolder = "//lfkqbwtweb02/c$/inetpub/wwwroot/deploy-docunex"
## The $sourceTemporaryDeployFolder is the same as $temporaryDeployFolder except it has a '*' on the end.
$sourceTemporaryDeployFolder = "//lfkqbwtweb02/c$/inetpub/wwwroot/deploy-docunex/*"
$baseHref = "docunex"
$webConfig = "Web.config"
$distInnerFolder = "dist\docunex"
## Build the project.
ng build --base-href=/$baseHref/ --configuration=production --prod
## Edit this --------------------------^
## Edit the contents above this line for your own environment.
## Copy contents of dist folder to the temporary deploy folder.
if (Test-Path $temporaryDeployFolder) {
Remove-Item $temporaryDeployFolder -Recurse -Force
}
## Copy web.config over.
Copy-Item .\src\$webConfig -Destination $distInnerFolder\web.config
Copy-Item $distInnerFolder\assets -Destination $temporaryDeployFolder\assets
## Copy contents of dist folder to the temporary deploy folder.
Copy-Item -Path $distInnerFolder\* -Destination $temporaryDeployFolder -Recurse -Force
## Copy the current site to a backup folder then copy the contents of the new app from
## the temporary deploy folder to the current web app folder.
if (-not (Test-Path $currentWebAppDirectory)) {
mkdir $currentWebAppDirectory
}
## If a backup folder already exists, delete it.
if (Test-Path $backupWebAppDirectory) {
Remove-Item $backupWebAppDirectory -Recurse -Force
}
## Make a backup of the current web application.
copy-item $currentWebAppDirectory $backupWebAppDirectory -Recurse -Force
## Copy the contents of the new web app to the current web app folder.
## We first copied the new web app to the server and then copy it again from the
## temp folder on the same server to the current directory because it should be
## faster to copy the contents from a folder on the same server. If there
## are users on the site at the time this offers minimal interruption of their service.
Copy-Item -Force -Recurse -Verbose $sourceTemporaryDeployFolder -Destination $currentWebAppDirectory
## Remove deploy folder.
Remove-Item $temporaryDeployFolder -Recurse -Force