Fix Windows deploy to use native OpenSSH instead of Git Bash.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+12
-15
@@ -16,8 +16,10 @@ $RepoRoot = git rev-parse --show-toplevel 2>$null
|
||||
if (-not $RepoRoot) { Fail "Not inside a git repository." }
|
||||
Set-Location $RepoRoot
|
||||
|
||||
# Git Bash on Windows mangles C:\... paths – use a repo-relative script path.
|
||||
if (Get-Command bash -ErrorAction SilentlyContinue) {
|
||||
# On Windows use native OpenSSH (same client as interactive "ssh" in PowerShell).
|
||||
# Git Bash ships its own ssh/known_hosts and breaks host key verification.
|
||||
$IsWindows = ($env:OS -match "Windows") -or ($PSVersionTable.PSPlatform -eq "Win32NT")
|
||||
if (-not $IsWindows -and (Get-Command bash -ErrorAction SilentlyContinue)) {
|
||||
& bash "./scripts/deploy.sh"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
@@ -27,6 +29,7 @@ $DeployDir = if ($env:DEPLOY_DIR) { $env:DEPLOY_DIR } else { "/opt/apps/Idle-Fan
|
||||
$HealthUrl = if ($env:DEPLOY_HEALTH_URL) { $env:DEPLOY_HEALTH_URL } else { "http://127.0.0.1:5000/" }
|
||||
$HealthRetries = if ($env:DEPLOY_HEALTH_RETRIES) { [int]$env:DEPLOY_HEALTH_RETRIES } else { 20 }
|
||||
$HealthInterval = if ($env:DEPLOY_HEALTH_INTERVAL) { [int]$env:DEPLOY_HEALTH_INTERVAL } else { 2 }
|
||||
$SshOpts = @("-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=accept-new")
|
||||
|
||||
$Branch = git rev-parse --abbrev-ref HEAD
|
||||
if ($Branch -eq "HEAD") { Fail "Detached HEAD – checkout a branch before deploying." }
|
||||
@@ -45,15 +48,6 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Write-Step "Deploying to ${DeployHost}:${DeployDir}"
|
||||
|
||||
$RemoteArgs = @(
|
||||
$DeployDir,
|
||||
$Branch,
|
||||
$LocalSha,
|
||||
$HealthUrl,
|
||||
[string]$HealthRetries,
|
||||
[string]$HealthInterval
|
||||
) -join " "
|
||||
|
||||
$RemoteScript = @'
|
||||
set -euo pipefail
|
||||
REMOTE_DIR="$1"
|
||||
@@ -124,10 +118,13 @@ info "Service status:"
|
||||
docker compose ps
|
||||
'@
|
||||
|
||||
$EncodedScript = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($RemoteScript))
|
||||
$SshCommand = "echo $EncodedScript | base64 -d | bash -s -- $RemoteArgs"
|
||||
|
||||
ssh -o BatchMode=yes $DeployHost $SshCommand
|
||||
$RemoteScript | & ssh @SshOpts $DeployHost bash -s -- `
|
||||
$DeployDir `
|
||||
$Branch `
|
||||
$LocalSha `
|
||||
$HealthUrl `
|
||||
"$HealthRetries" `
|
||||
"$HealthInterval"
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Write-Step "Deployment finished successfully."
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ REMOTE_DIR="${DEPLOY_DIR:-/opt/apps/Idle-Fantasy-Save-Viewer}"
|
||||
HEALTH_URL="${DEPLOY_HEALTH_URL:-http://127.0.0.1:5000/}"
|
||||
HEALTH_RETRIES="${DEPLOY_HEALTH_RETRIES:-20}"
|
||||
HEALTH_INTERVAL="${DEPLOY_HEALTH_INTERVAL:-2}"
|
||||
SSH_OPTS=(-o BatchMode=yes -o StrictHostKeyChecking=accept-new)
|
||||
|
||||
info() { printf '==> %s\n' "$*"; }
|
||||
err() { printf 'ERROR: %s\n' "$*" >&2; }
|
||||
@@ -52,7 +53,7 @@ REMOTE_SHA="$(git rev-parse HEAD)"
|
||||
|
||||
info "Deploying to $REMOTE_HOST:$REMOTE_DIR"
|
||||
|
||||
ssh -o BatchMode=yes "$REMOTE_HOST" bash -s -- \
|
||||
ssh "${SSH_OPTS[@]}" "$REMOTE_HOST" bash -s -- \
|
||||
"$REMOTE_DIR" \
|
||||
"$BRANCH" \
|
||||
"$REMOTE_SHA" \
|
||||
|
||||
Reference in New Issue
Block a user