-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-site.ps1
62 lines (58 loc) · 1.84 KB
/
deploy-site.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
# Setup env variables
param (
[Parameter(Mandatory=$true)][string]$UserName,
[Parameter(Mandatory=$true)][string]$Password,
[Parameter(Mandatory=$true)][string]$HostIP,
[Parameter(Mandatory=$true)][string]$HostKey
)
$CurrentDirectory = Get-Location
# Download and build site
git clone -b master --single-branch https://github.com/CTOpenData/analytics.ct.gov.git analytics-site
Push-Location .\analytics-site
bundle
bundle exec jekyll build
Remove-Item .\_site\fake-data\ -recurse
Remove-Item .\_site\docker-compose.yml
Remove-Item .\_site\Dockerfile
Remove-Item .\_site\Dockerfile.production
Remove-Item .\_site\nginx.conf
Remove-Item .\_site\package-lock.json
Remove-Item .\_site\package.json
Remove-Item .\_site\webpack.config.js
Pop-Location
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = $HostIP
UserName = $UserName
Password = $Password
SshHostKeyFingerprint = $HostKey
}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
Write-Host "Uploading files"
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "$CurrentDirectory\analytics-site\_site\", "analytics", $true)
$synchronizationResult.Check()
Write-Host $synchronizationResult.Uploads
foreach ($uploadedFile in $synchronizationResult.Uploads)
{
if ($uploadedFile.Error -eq $Null)
{
Write-Host "Upload of $($uploadedFile.FileName) succeeded"
}
else
{
Write-Host (
"Upload of $($uploadedFile.FileName) failed: $($uploadedFile.Error.Message)")
}
}
}
finally
{
$session.Dispose()
}