mirror of
https://github.com/ptarmiganlabs/butler-sos.git
synced 2025-12-19 17:58:18 -05:00
Add automated Windows insider build deployment to host2-win
Co-authored-by: mountaindude <1029262+mountaindude@users.noreply.github.com>
This commit is contained in:
153
.github/workflows/insiders-build.yaml
vendored
153
.github/workflows/insiders-build.yaml
vendored
@@ -435,3 +435,156 @@ jobs:
|
||||
with:
|
||||
name: ${{ matrix.artifact_insider }}
|
||||
path: ${{ matrix.artifact_insider }}
|
||||
|
||||
deploy-windows-insider:
|
||||
needs: insiders-build
|
||||
runs-on: host2-win
|
||||
if: success()
|
||||
steps:
|
||||
- name: Download Windows insider build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: butler-sos--win-x64--${{ github.sha }}.zip
|
||||
path: ./download
|
||||
|
||||
- name: Deploy Windows insider build
|
||||
shell: pwsh
|
||||
continue-on-error: true
|
||||
run: |
|
||||
Write-Host "Starting deployment of Butler SOS insiders build..."
|
||||
|
||||
# Define variables
|
||||
$serviceName = "Butler SOS insiders build"
|
||||
$artifactPath = ".\download\butler-sos--win-x64--${{ github.sha }}.zip"
|
||||
$deployPath = "C:\butler-sos-insider"
|
||||
|
||||
try {
|
||||
# Check if artifact exists
|
||||
if (-not (Test-Path $artifactPath)) {
|
||||
throw "Artifact not found at path: $artifactPath"
|
||||
}
|
||||
|
||||
Write-Host "Artifact found: $artifactPath"
|
||||
|
||||
# Stop the service if it exists
|
||||
Write-Host "Checking if service '$serviceName' exists..."
|
||||
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||
|
||||
if ($service) {
|
||||
Write-Host "Service found. Current status: $($service.Status)"
|
||||
|
||||
if ($service.Status -eq 'Running') {
|
||||
Write-Host "Stopping service '$serviceName'..."
|
||||
Stop-Service -Name $serviceName -Force -ErrorAction Stop
|
||||
|
||||
# Wait for service to stop
|
||||
$timeout = 30
|
||||
$timer = 0
|
||||
do {
|
||||
Start-Sleep -Seconds 1
|
||||
$timer++
|
||||
$service = Get-Service -Name $serviceName
|
||||
} while ($service.Status -ne 'Stopped' -and $timer -lt $timeout)
|
||||
|
||||
if ($service.Status -ne 'Stopped') {
|
||||
throw "Failed to stop service within $timeout seconds"
|
||||
}
|
||||
|
||||
Write-Host "Service stopped successfully"
|
||||
} else {
|
||||
Write-Host "Service is already stopped"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Service '$serviceName' not found. Will continue with deployment."
|
||||
}
|
||||
|
||||
# Create deployment directory if it doesn't exist
|
||||
if (-not (Test-Path $deployPath)) {
|
||||
Write-Host "Creating deployment directory: $deployPath"
|
||||
New-Item -ItemType Directory -Path $deployPath -Force
|
||||
}
|
||||
|
||||
# Extract the zip file
|
||||
Write-Host "Extracting artifact to $deployPath..."
|
||||
Expand-Archive -Path $artifactPath -DestinationPath $deployPath -Force
|
||||
|
||||
Write-Host "Deployment files extracted successfully"
|
||||
|
||||
# List extracted contents
|
||||
Write-Host "Extracted files:"
|
||||
Get-ChildItem -Path $deployPath -Recurse | Format-Table Name, Length, LastWriteTime
|
||||
|
||||
# Start the service if it exists
|
||||
if ($service) {
|
||||
Write-Host "Starting service '$serviceName'..."
|
||||
Start-Service -Name $serviceName -ErrorAction Stop
|
||||
|
||||
# Wait for service to start
|
||||
$timeout = 30
|
||||
$timer = 0
|
||||
do {
|
||||
Start-Sleep -Seconds 1
|
||||
$timer++
|
||||
$service = Get-Service -Name $serviceName
|
||||
} while ($service.Status -ne 'Running' -and $timer -lt $timeout)
|
||||
|
||||
if ($service.Status -eq 'Running') {
|
||||
Write-Host "Service started successfully"
|
||||
} else {
|
||||
throw "Failed to start service within $timeout seconds. Service status: $($service.Status)"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Service not found. Binary deployed but service needs to be configured manually."
|
||||
}
|
||||
|
||||
Write-Host "✅ Deployment completed successfully!"
|
||||
|
||||
} catch {
|
||||
Write-Host "❌ Deployment failed: $($_.Exception.Message)" -ForegroundColor Red
|
||||
Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Verify deployment
|
||||
shell: pwsh
|
||||
continue-on-error: true
|
||||
run: |
|
||||
Write-Host "Verifying deployment..."
|
||||
|
||||
$serviceName = "Butler SOS insiders build"
|
||||
$deployPath = "C:\butler-sos-insider"
|
||||
|
||||
try {
|
||||
# Check if deployment directory exists and has files
|
||||
if (Test-Path $deployPath) {
|
||||
Write-Host "Deployment directory exists: $deployPath"
|
||||
$files = Get-ChildItem -Path $deployPath -Recurse
|
||||
Write-Host "Number of files in deployment: $($files.Count)"
|
||||
|
||||
# Check for the main executable
|
||||
$executable = Get-ChildItem -Path $deployPath -Name "butler-sos.exe" -Recurse
|
||||
if ($executable) {
|
||||
Write-Host "✅ Main executable found: $executable"
|
||||
} else {
|
||||
Write-Host "⚠️ Main executable not found"
|
||||
}
|
||||
} else {
|
||||
Write-Host "❌ Deployment directory not found"
|
||||
}
|
||||
|
||||
# Check service status
|
||||
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||
if ($service) {
|
||||
Write-Host "Service '$serviceName' status: $($service.Status)"
|
||||
if ($service.Status -eq 'Running') {
|
||||
Write-Host "✅ Service is running"
|
||||
} else {
|
||||
Write-Host "⚠️ Service is not running"
|
||||
}
|
||||
} else {
|
||||
Write-Host "⚠️ Service '$serviceName' not found"
|
||||
}
|
||||
|
||||
} catch {
|
||||
Write-Host "❌ Verification failed: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user