Add deployment automation system with build/publish workflow and fix path resolution

This commit introduces a complete deployment automation system for Windows Server deployment:

New Features:
- Publish-And-Deploy.ps1: Interactive console for building locally and transferring to server
  * Supports auto-detection of transfer method (Windows Share or SSH)
  * Configurable via deploy-config.json
  * Integrated with Build-ROA2WEB.ps1 for consistent builds
- Check-And-Deploy.ps1: Server-side auto-deployment script
  * Monitors transfer directory for new packages
  * Automatically deploys when new version detected
  * Integrates with ROA2WEB-Console.ps1 for deployment
- Setup-AutoDeploy.ps1: Configures scheduled task for auto-deployment
- DEPLOYMENT_AUTOMATION.md: Complete documentation for automation workflow

Bug Fixes:
- Fix path resolution in Publish-And-Deploy.ps1: Added Resolve-FullPath function to correctly resolve ../deploy-package path
- Fix ROA2WEB-Console.ps1 exit codes: Properly return boolean values and exit codes in non-interactive mode
- Fix Build-ROA2WEB.ps1 script copying: Added debug output and force deletion to avoid caching issues

Enhancements:
- ROA2WEB-Console.ps1: Support for ROA2WEB_SOURCE environment variable for flexible source paths
- Build-ROA2WEB.ps1: Enhanced debug output for troubleshooting script copying issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-14 14:59:47 +02:00
parent 914ab0107e
commit 87859e5510
7 changed files with 2714 additions and 14 deletions

View File

@@ -53,8 +53,14 @@ $ErrorActionPreference = "Stop"
# GLOBAL CONFIGURATION
# =============================================================================
# Auto-detect source path: if running from scripts/ subdirectory, use parent
$detectedSourcePath = if ((Split-Path $PSScriptRoot -Leaf) -eq "scripts") {
# Auto-detect source path with priority:
# 1. Environment variable ROA2WEB_SOURCE (set by Check-And-Deploy.ps1)
# 2. If running from scripts/ subdirectory, use parent
# 3. Otherwise use script root
$detectedSourcePath = if ($env:ROA2WEB_SOURCE) {
Write-Host "[INFO] Using source path from environment: $env:ROA2WEB_SOURCE" -ForegroundColor Cyan
$env:ROA2WEB_SOURCE
} elseif ((Split-Path $PSScriptRoot -Leaf) -eq "scripts") {
Split-Path $PSScriptRoot -Parent
} else {
$PSScriptRoot
@@ -1649,16 +1655,27 @@ function Execute-ManageAction {
function Execute-DeployAction {
param([string]$Component)
# Execute deployment and capture only the boolean result
$success = switch ($Component) {
"Backend" { Deploy-Backend }
"TelegramBot" { Deploy-TelegramBot }
"Backend" {
$result = Deploy-Backend
$result # Explicitly output the boolean
}
"TelegramBot" {
$result = Deploy-TelegramBot
$result # Explicitly output the boolean
}
"All" {
$backendOk = Deploy-Backend
$telegramOk = Deploy-TelegramBot
$backendOk -and $telegramOk
# Return combined result
($backendOk -and $telegramOk)
}
}
# Ensure $success is boolean
$success = [bool]$success
if ($success) {
Write-Host "`n" + ("=" * 70) -ForegroundColor Cyan
Write-Host " DEPLOYMENT COMPLETED" -ForegroundColor Green
@@ -1668,6 +1685,9 @@ function Execute-DeployAction {
Write-Host " DEPLOYMENT FAILED" -ForegroundColor Red
Write-Host ("=" * 70) -ForegroundColor Cyan
}
# Explicitly return boolean value
return $success
}
function Show-AllStatus {
@@ -1698,16 +1718,37 @@ function Main {
# Non-interactive mode
if ($NonInteractive -and $Action) {
switch ($Action) {
"DeployBackend" { Execute-DeployAction -Component "Backend" }
"DeployTelegramBot" { Execute-DeployAction -Component "TelegramBot" }
"DeployAll" { Execute-DeployAction -Component "All" }
"StartAll" { Execute-ManageAction -Action "Start" -Component "All" }
"StopAll" { Execute-ManageAction -Action "Stop" -Component "All" }
"RestartAll" { Execute-ManageAction -Action "Restart" -Component "All" }
"Status" { Show-AllStatus }
try {
$success = switch ($Action) {
"DeployBackend" { Execute-DeployAction -Component "Backend" }
"DeployTelegramBot" { Execute-DeployAction -Component "TelegramBot" }
"DeployAll" { Execute-DeployAction -Component "All" }
"StartAll" { Execute-ManageAction -Action "Start" -Component "All"; $true }
"StopAll" { Execute-ManageAction -Action "Stop" -Component "All"; $true }
"RestartAll" { Execute-ManageAction -Action "Restart" -Component "All"; $true }
"Status" { Show-AllStatus; $true }
default { $false }
}
# Ensure boolean
$success = [bool]$success
# Debug output
Write-Host "`n[DEBUG] Action: $Action, Success: $success, Type: $($success.GetType().Name)" -ForegroundColor Magenta
if ($success) {
Write-Host "[DEBUG] Exiting with code 0 (success)" -ForegroundColor Magenta
exit 0
} else {
Write-Host "[DEBUG] Exiting with code 1 (failure)" -ForegroundColor Magenta
exit 1
}
} catch {
Write-Host "`n[ERROR] Unhandled exception: $($_.Exception.Message)" -ForegroundColor Red
Write-Host "[ERROR] Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red
Write-Host "[DEBUG] Exiting with code 1 (exception)" -ForegroundColor Magenta
exit 1
}
return
}
# Interactive mode - main loop