feat: expose skip-artifact as workflow input in action.yml

action.yml:
  - Add skip-artifact input (default: 'false').
  - Forward as INPUT_SKIP_ARTIFACT env var to the PS run step.
  - Pass SkipArtifact=true to Invoke-CIJob.ps1 when set.
  - Gate 'Upload artifacts' step on inputs.skip-artifact != 'true'.

Invoke-CIJob.ps1:
  - Restore -SkipArtifact switch; skips Phase 6 and logs 'skipped' event.

Invoke-RemoteBuild.ps1:
  - Restore -SkipArtifact switch; skips packaging inside the guest.
  - Error message updated to mention skip-artifact workflow input.
This commit is contained in:
Simone
2026-05-12 22:05:17 +02:00
parent a6acf1eef7
commit 9007934dca
3 changed files with 38 additions and 8 deletions
+13 -5
View File
@@ -126,6 +126,10 @@ param(
# and VMware Tools HGFS driver present in the guest.
[switch] $UseSharedCache,
# Skip artifact packaging entirely. Use for jobs that produce no output.
# When absent, missing GuestArtifactSource after a successful build is an error.
[switch] $SkipArtifact,
# Guest OS type — Linux uses SSH instead of WinRM.
[ValidateSet('Windows', 'Linux')]
[string] $GuestOS = 'Windows',
@@ -427,7 +431,7 @@ try {
# ── Custom build command (e.g. python, msbuild, cmake…) ──────────
Write-Host "[Invoke-RemoteBuild] Running build command: $BuildCommand"
$buildExit = Invoke-Command -Session $session -ScriptBlock {
param($workDir, $cmd, $artifactZip, $artifactSrc, $useCache, $extraEnv)
param($workDir, $cmd, $artifactZip, $artifactSrc, $useCache, $extraEnv, $skipArt)
# Unbuffered Python output — lines appear in real-time instead of being held in buffer
$env:PYTHONUNBUFFERED = '1'
if ($useCache) {
@@ -442,14 +446,14 @@ try {
& cmd /c "$cmd 2>&1" | ForEach-Object { Write-Host $_ }
$exit = $LASTEXITCODE
if ($exit -eq 0) {
if ($exit -eq 0 -and -not $skipArt) {
$archiveDir = Split-Path $artifactZip -Parent
if (-not (Test-Path $archiveDir)) {
New-Item -ItemType Directory -Path $archiveDir -Force | Out-Null
}
$srcPath = Join-Path $workDir $artifactSrc
if (-not (Test-Path $srcPath)) {
throw "Artifact source directory not found: $srcPath. Build succeeded (exit 0) but produced no output. Check GuestArtifactSource."
throw "Artifact source directory not found: $srcPath. Build succeeded (exit 0) but produced no output. Check GuestArtifactSource or set skip-artifact: 'true' in the workflow."
}
else {
$7zip = 'C:\Program Files\7-Zip\7z.exe'
@@ -465,7 +469,7 @@ try {
}
return $exit
} -ArgumentList $GuestWorkDir, $BuildCommand, $GuestArtifactZip, $GuestArtifactSource, $UseSharedCache.IsPresent, $ExtraGuestEnv
} -ArgumentList $GuestWorkDir, $BuildCommand, $GuestArtifactZip, $GuestArtifactSource, $UseSharedCache.IsPresent, $ExtraGuestEnv, $SkipArtifact.IsPresent
if ($buildExit -ne 0) {
throw "Build command failed (exit $buildExit)"
@@ -528,7 +532,11 @@ try {
}
}
Write-Host "[Invoke-RemoteBuild] Build succeeded. Artifact at $GuestArtifactZip"
if ($SkipArtifact) {
Write-Host '[Invoke-RemoteBuild] Build succeeded. Artifact packaging skipped (-SkipArtifact).'
} else {
Write-Host "[Invoke-RemoteBuild] Build succeeded. Artifact at $GuestArtifactZip"
}
}
finally {
Remove-PSSession $session -ErrorAction SilentlyContinue