EENE Dashboard upload to Gitea
This commit is contained in:
@@ -34,8 +34,35 @@ $giteaHost = '172.16.10.175'
|
||||
$giteaPort = 222
|
||||
$giteaRepo = 'RyuWonJun/eene_dashboard.git'
|
||||
$sshConfig = Join-Path $env:USERPROFILE '.ssh\config'
|
||||
$test = ssh -F $sshConfig -i $keyPath -T "git@${giteaHost}" -p $giteaPort -o IdentitiesOnly=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new 2>&1 | Out-String
|
||||
Write-Host $test.TrimEnd()
|
||||
|
||||
$sshArgs = @(
|
||||
'-i', $keyPath,
|
||||
'-T', "git@${giteaHost}",
|
||||
'-p', $giteaPort,
|
||||
'-o', 'IdentitiesOnly=yes',
|
||||
'-o', 'ConnectTimeout=10',
|
||||
'-o', 'StrictHostKeyChecking=accept-new'
|
||||
)
|
||||
if (Test-Path $sshConfig) {
|
||||
$sshArgs = @('-F', $sshConfig) + $sshArgs
|
||||
}
|
||||
|
||||
$prevEap = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$sshLines = [System.Collections.Generic.List[string]]::new()
|
||||
try {
|
||||
& ssh @sshArgs 2>&1 | ForEach-Object { [void]$sshLines.Add("$($_)".Trim()) }
|
||||
} finally {
|
||||
$ErrorActionPreference = $prevEap
|
||||
}
|
||||
$test = ($sshLines | Where-Object { $_ }) -join "`n"
|
||||
if (-not $test) { $test = '' }
|
||||
|
||||
if ($test) {
|
||||
Write-Host $test
|
||||
} else {
|
||||
Write-Host ' (no SSH message — checking exit code)' -ForegroundColor DarkGray
|
||||
}
|
||||
if ($test -match 'Permission denied') {
|
||||
Write-Host ''
|
||||
Write-Host '[ERROR] Gitea rejected this key.' -ForegroundColor Red
|
||||
@@ -50,11 +77,19 @@ if ($test -match 'Permission denied') {
|
||||
exit 1
|
||||
}
|
||||
if ($test -notmatch 'successfully authenticated') {
|
||||
Write-Host ''
|
||||
Write-Host '[ERROR] Unexpected SSH response. Check port and deploy key.' -ForegroundColor Red
|
||||
exit 1
|
||||
if ($LASTEXITCODE -eq 0 -and -not $test) {
|
||||
Write-Host ' SSH OK (exit 0)' -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host ''
|
||||
Write-Host '[ERROR] Unexpected SSH response. Check port and deploy key.' -ForegroundColor Red
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host " ssh exit code: $LASTEXITCODE" -ForegroundColor Yellow
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Host ' SSH OK' -ForegroundColor Green
|
||||
}
|
||||
Write-Host ' SSH OK' -ForegroundColor Green
|
||||
|
||||
Set-Location $projectRoot
|
||||
|
||||
|
||||
Reference in New Issue
Block a user