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." }
|
if (-not $RepoRoot) { Fail "Not inside a git repository." }
|
||||||
Set-Location $RepoRoot
|
Set-Location $RepoRoot
|
||||||
|
|
||||||
# Git Bash on Windows mangles C:\... paths – use a repo-relative script path.
|
# On Windows use native OpenSSH (same client as interactive "ssh" in PowerShell).
|
||||||
if (Get-Command bash -ErrorAction SilentlyContinue) {
|
# 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"
|
& bash "./scripts/deploy.sh"
|
||||||
exit $LASTEXITCODE
|
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/" }
|
$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 }
|
$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 }
|
$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
|
$Branch = git rev-parse --abbrev-ref HEAD
|
||||||
if ($Branch -eq "HEAD") { Fail "Detached HEAD – checkout a branch before deploying." }
|
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}"
|
Write-Step "Deploying to ${DeployHost}:${DeployDir}"
|
||||||
|
|
||||||
$RemoteArgs = @(
|
|
||||||
$DeployDir,
|
|
||||||
$Branch,
|
|
||||||
$LocalSha,
|
|
||||||
$HealthUrl,
|
|
||||||
[string]$HealthRetries,
|
|
||||||
[string]$HealthInterval
|
|
||||||
) -join " "
|
|
||||||
|
|
||||||
$RemoteScript = @'
|
$RemoteScript = @'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
REMOTE_DIR="$1"
|
REMOTE_DIR="$1"
|
||||||
@@ -124,10 +118,13 @@ info "Service status:"
|
|||||||
docker compose ps
|
docker compose ps
|
||||||
'@
|
'@
|
||||||
|
|
||||||
$EncodedScript = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($RemoteScript))
|
$RemoteScript | & ssh @SshOpts $DeployHost bash -s -- `
|
||||||
$SshCommand = "echo $EncodedScript | base64 -d | bash -s -- $RemoteArgs"
|
$DeployDir `
|
||||||
|
$Branch `
|
||||||
ssh -o BatchMode=yes $DeployHost $SshCommand
|
$LocalSha `
|
||||||
|
$HealthUrl `
|
||||||
|
"$HealthRetries" `
|
||||||
|
"$HealthInterval"
|
||||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||||
|
|
||||||
Write-Step "Deployment finished successfully."
|
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_URL="${DEPLOY_HEALTH_URL:-http://127.0.0.1:5000/}"
|
||||||
HEALTH_RETRIES="${DEPLOY_HEALTH_RETRIES:-20}"
|
HEALTH_RETRIES="${DEPLOY_HEALTH_RETRIES:-20}"
|
||||||
HEALTH_INTERVAL="${DEPLOY_HEALTH_INTERVAL:-2}"
|
HEALTH_INTERVAL="${DEPLOY_HEALTH_INTERVAL:-2}"
|
||||||
|
SSH_OPTS=(-o BatchMode=yes -o StrictHostKeyChecking=accept-new)
|
||||||
|
|
||||||
info() { printf '==> %s\n' "$*"; }
|
info() { printf '==> %s\n' "$*"; }
|
||||||
err() { printf 'ERROR: %s\n' "$*" >&2; }
|
err() { printf 'ERROR: %s\n' "$*" >&2; }
|
||||||
@@ -52,7 +53,7 @@ REMOTE_SHA="$(git rev-parse HEAD)"
|
|||||||
|
|
||||||
info "Deploying to $REMOTE_HOST:$REMOTE_DIR"
|
info "Deploying to $REMOTE_HOST:$REMOTE_DIR"
|
||||||
|
|
||||||
ssh -o BatchMode=yes "$REMOTE_HOST" bash -s -- \
|
ssh "${SSH_OPTS[@]}" "$REMOTE_HOST" bash -s -- \
|
||||||
"$REMOTE_DIR" \
|
"$REMOTE_DIR" \
|
||||||
"$BRANCH" \
|
"$BRANCH" \
|
||||||
"$REMOTE_SHA" \
|
"$REMOTE_SHA" \
|
||||||
|
|||||||
Reference in New Issue
Block a user