From b150fa5a1c2d52589ae8bd812db5e0c28cf9ac57 Mon Sep 17 00:00:00 2001 From: James Brundage <@github.com> Date: Thu, 15 Feb 2024 19:01:37 -0800 Subject: [PATCH] feat: Export-PipeScript Build Summary and Output Improvement ( Fixes #914 ) --- Commands/PipeScript/Export-PipeScript.ps1 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Commands/PipeScript/Export-PipeScript.ps1 b/Commands/PipeScript/Export-PipeScript.ps1 index a36a16e89..ba310d5a4 100644 --- a/Commands/PipeScript/Export-PipeScript.ps1 +++ b/Commands/PipeScript/Export-PipeScript.ps1 @@ -231,11 +231,29 @@ function Export-Pipescript { if ($env:GITHUB_WORKSPACE -or ($host.Name -eq 'Default Host')) { $FileBuildEnded = [DateTime]::now + "$($buildFile.Source)", "$('=' * $buildFile.Source.Length)", "Output:" -join [Environment]::newLine | Out-Host - if ($buildOutput -is [Management.Automation.ErrorRecord]) { + if ($buildOutput -is [Management.Automation.ErrorRecord] -or $buildOutput -is [Exception]) { $buildOutput | Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + @( + "* ❌ ``$($buildFile.Source | Split-Path -Leaf)`` !!!:" + '~~~' + $($buildOutput | Out-String) + '~~~' + ) -join [Environment]::newLine| Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } } else { - $buildOutput.FullName | Out-Host + if ($env:GITHUB_STEP_SUMMARY) { + @( + "* ✅ ``$($buildFile.Source | Split-Path -Leaf)`` ⋙ $(if ($buildOutput -is [IO.FileInfo]) { $buildOutput.Name })" + " * $(@(if ($buildOutput -is [object[]]) { + foreach ($buildOutObject in $buildOutput) { + $buildOutput.Name + } + }) -join ([Environment]::newLine + ' * '))" + ) -join [Environment]::newLine | Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY + } } $totalProcessTime = 0 if ($env:ACTIONS_RUNNER_DEBUG) {