forked from funnelweblog/FunnelWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deploy_To_Git.ps1
116 lines (94 loc) · 2.62 KB
/
Deploy_To_Git.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
param([switch]$init, [switch]$updateConfig, [switch]$dontBuild)
$ErrorActionPreference = "Stop";
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$root = Get-ScriptDirectory
if ($dontBuild -ne $true)
{
& $root\build.bat NOPAUSE
}
#Get Configuration File
if (!(Test-Path $root\GitRepoConfig.xml))
{
$config = [xml]'<gitRepoConfig>
<repository></repository>
</gitRepoConfig>'
$config.Save("$root\GitRepoConfig.xml")
}
else
{
$config = New-Object XML
$config.Load("$root\GitRepoConfig.xml")
}
#Get repo
if ([string]::IsNullOrEmpty($config.gitRepoConfig.repository))
{
$repo = Read-Host "Enter git repository url"
$config.gitRepoConfig.repository = [string]$repo
$config.Save("$root\GitRepoConfig.xml")
}
else
{
$repo = $config.gitRepoConfig.repository
}
$x86git = "C:\Program Files (x86)\Git\bin\git.exe"
$git = "C:\Program Files (x86)\Git\bin\git.exe"
if (Test-Path "C:\Program Files (x86)\Git\bin\git.exe")
{
$git = $x86git
}
$deployTempDir = "$env:temp\FunnelWebGitDeploy"
if (Test-Path "$deployTempDir")
{
Remove-Item "$deployTempDir\*" -recurse -force
Remove-Item "$deployTempDir" -force
}
if (!(Test-Path "$deployTempDir"))
{
[System.IO.Directory]::CreateDirectory("$deployTempDir")
}
write-host "Temporary directory is $deployTempDir"
pushd "$deployTempDir"
if ($init -eq $false)
{
& $git clone $repo .
& $git checkout
}
else
{
& $git init
& $git remote add origin $repo
}
# copy new stuff over
copy "$root\build\published\*" "$deployTempDir" -recurse -force
if ($updateConfig -eq $false -and !(Test-Path "$deployTempDir\my.config"))
{
$myConfig = New-Object XML
$myConfig.Load("$deployTempDir\my.config.sample")
$funnelWebUsername = Read-Host "SETUP: Enter your FunnelWeb Administrator Username"
$funnelWebPassword = Read-Host "SETUP: Enter your FunnelWeb Administrator Password"
foreach($setting in $myConfig.selectnodes("/funnelweb/setting"))
{
switch($setting.key)
{
"funnelweb.configuration.authentication.username" { $setting.SetAttribute("value", $funnelWebUsername) }
"funnelweb.configuration.authentication.password" { $setting.SetAttribute("value", $funnelWebPassword) }
}
}
$myConfig.Save("$deployTempDir\my.config")
}
if ($updateConfig -eq $true)
{
write-host "Opening my.config for editing before deployment"
& notepad $deployTempDir\my.config | Out-Null
}
### Compatibility Steps
#Remove Obsolete Extensions
#Update repo
& $git add "-A"
& $git commit "-m Update FunnelWeb build"
& $git push origin master
popd