4.0.1 - fixes
This commit is contained in:
+41
-2
@@ -1,7 +1,8 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[switch]$Force,
|
||||
[switch]$SkipSiteCheck
|
||||
[switch]$SkipSiteCheck,
|
||||
[string]$Service
|
||||
)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -25,6 +26,7 @@ $VerifyUrl = 'https://www.goodwalk.co.nz/api/health'
|
||||
$RemoteArchivePath = '/tmp/goodwalk-deploy.tgz'
|
||||
$RemoteHelperPath = '/tmp/goodwalk-deploy-remote.sh'
|
||||
$LocalRemoteHelperPath = Join-Path $LocalProjectPath 'scripts\deploy-remote.sh'
|
||||
$GeneratedHomepageContentPath = Join-Path $LocalProjectPath 'deploy-data\homepage-content.json'
|
||||
|
||||
function Assert-NotBlank {
|
||||
param(
|
||||
@@ -108,6 +110,31 @@ function New-DeployArchive {
|
||||
return $archivePath
|
||||
}
|
||||
|
||||
function Export-HomepageContent {
|
||||
param(
|
||||
[string]$ProjectPath,
|
||||
[string]$OutputPath
|
||||
)
|
||||
|
||||
$scriptPath = Join-Path $ProjectPath 'scripts\export-homepage-content.mjs'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $scriptPath)) {
|
||||
throw "Homepage content export script not found: $scriptPath"
|
||||
}
|
||||
|
||||
Push-Location $ProjectPath
|
||||
try {
|
||||
Invoke-External -FilePath 'node' -Arguments @(
|
||||
'--experimental-strip-types',
|
||||
$scriptPath,
|
||||
$OutputPath
|
||||
)
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-SiteCheck {
|
||||
param([string]$Url)
|
||||
|
||||
@@ -126,6 +153,7 @@ function Invoke-SiteCheck {
|
||||
Assert-Command ssh
|
||||
Assert-Command scp
|
||||
Assert-Command tar
|
||||
Assert-Command node
|
||||
|
||||
Assert-NotBlank -Name 'SshUser' -Value $SshUser
|
||||
Assert-NotBlank -Name 'ServerHost' -Value $ServerHost
|
||||
@@ -134,6 +162,10 @@ Assert-NotBlank -Name 'RemoteDeploymentPath' -Value $RemoteDeploymentPath
|
||||
Assert-NotBlank -Name 'ComposeFileName' -Value $ComposeFileName
|
||||
Assert-NotBlank -Name 'DockerProjectName' -Value $DockerProjectName
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($Service)) {
|
||||
$Service = $Service.Trim()
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($SshConfigPath) -and -not (Test-Path -LiteralPath $SshConfigPath)) {
|
||||
throw "SSH config file not found: $SshConfigPath"
|
||||
}
|
||||
@@ -166,6 +198,9 @@ Write-Host "[deploy] Remote compose file: $ComposeFileName"
|
||||
Write-Host "[deploy] Docker project name: $DockerProjectName"
|
||||
Write-Host "[deploy] SSH target: $sshTarget"
|
||||
Write-Host "[deploy] SSH config: $SshConfigPath"
|
||||
if (-not [string]::IsNullOrWhiteSpace($Service)) {
|
||||
Write-Host "[deploy] Target service: $Service"
|
||||
}
|
||||
if ([string]::IsNullOrWhiteSpace($SshKeyPath)) {
|
||||
Write-Host '[deploy] SSH auth: interactive password prompt'
|
||||
} else {
|
||||
@@ -188,6 +223,10 @@ if (-not $Force) {
|
||||
$archivePath = $null
|
||||
|
||||
try {
|
||||
Write-Host ''
|
||||
Write-Host '[deploy] Exporting current homepage content for PostgreSQL sync'
|
||||
Export-HomepageContent -ProjectPath $LocalProjectPath -OutputPath $GeneratedHomepageContentPath
|
||||
|
||||
Write-Host ''
|
||||
Write-Host '[deploy] Creating deployment archive'
|
||||
$archivePath = New-DeployArchive -ProjectPath $LocalProjectPath
|
||||
@@ -215,7 +254,7 @@ try {
|
||||
$ComposeFileName,
|
||||
'--project-name',
|
||||
$DockerProjectName
|
||||
))
|
||||
) + $(if (-not [string]::IsNullOrWhiteSpace($Service)) { @('--service', $Service) } else { @() }))
|
||||
|
||||
Write-Host ''
|
||||
Write-Host '[deploy] Cleaning remote temporary files'
|
||||
|
||||
Reference in New Issue
Block a user