Use temp script for Tower PowerShell deploy
This commit is contained in:
@@ -58,10 +58,37 @@ if [ -x scripts/verify_browser_runtime.sh ]; then
|
||||
fi
|
||||
'@
|
||||
|
||||
$remoteCommand = "REMOTE_PATH='$RemotePath' REMOTE_BRANCH='$RemoteBranch' REMOTE_REPO='$RemoteRepo' FRONTEND_URL='$FrontendUrl' DEPLOY_BOOTSTRAP='$bootstrapValue' DEPLOY_GEOINTEL_INSTALL_AI='$InstallAi' bash -s"
|
||||
|
||||
$utf8NoBom = [System.Text.UTF8Encoding]::new($false)
|
||||
[Console]::OutputEncoding = $utf8NoBom
|
||||
$OutputEncoding = $utf8NoBom
|
||||
$localScriptPath = [System.IO.Path]::GetTempFileName()
|
||||
$remoteScriptPath = "/tmp/geointel-deploy-$([System.Guid]::NewGuid().ToString('N')).sh"
|
||||
|
||||
$remoteScript | ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -i $SshKey $RemoteHost $remoteCommand
|
||||
try {
|
||||
[System.IO.File]::WriteAllText($localScriptPath, $remoteScript, $utf8NoBom)
|
||||
|
||||
$scpArgs = @(
|
||||
"-o", "BatchMode=yes",
|
||||
"-o", "StrictHostKeyChecking=accept-new",
|
||||
"-i", $SshKey,
|
||||
$localScriptPath,
|
||||
"${RemoteHost}:$remoteScriptPath"
|
||||
)
|
||||
& scp @scpArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
$remoteRunCommand = "REMOTE_PATH='$RemotePath' REMOTE_BRANCH='$RemoteBranch' REMOTE_REPO='$RemoteRepo' FRONTEND_URL='$FrontendUrl' DEPLOY_BOOTSTRAP='$bootstrapValue' DEPLOY_GEOINTEL_INSTALL_AI='$InstallAi' bash '$remoteScriptPath'; status=`$?; rm -f '$remoteScriptPath'; exit `$status"
|
||||
$sshRunArgs = @(
|
||||
"-o", "BatchMode=yes",
|
||||
"-o", "StrictHostKeyChecking=accept-new",
|
||||
"-i", $SshKey,
|
||||
$RemoteHost,
|
||||
$remoteRunCommand
|
||||
)
|
||||
& ssh @sshRunArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
} finally {
|
||||
Remove-Item -LiteralPath $localScriptPath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user