From b4dd0983b17907e9a361b0cb7142e2abd1f3b6c7 Mon Sep 17 00:00:00 2001 From: elpatron Date: Fri, 19 Jun 2026 17:21:54 +0200 Subject: [PATCH] Fix Windows deploy to use native OpenSSH instead of Git Bash. Co-authored-by: Cursor --- scripts/deploy.ps1 | 27 ++++++++++++--------------- scripts/deploy.sh | 3 ++- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/scripts/deploy.ps1 b/scripts/deploy.ps1 index 315a9bc..b0914d8 100644 --- a/scripts/deploy.ps1 +++ b/scripts/deploy.ps1 @@ -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." diff --git a/scripts/deploy.sh b/scripts/deploy.sh index a050f28..17c42bc 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -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" \