diff --git a/src/functions/public/Commands/Get-GitHubOutput.ps1 b/src/functions/public/Commands/Get-GitHubOutput.ps1 index ed7b7ff67..6285baae6 100644 --- a/src/functions/public/Commands/Get-GitHubOutput.ps1 +++ b/src/functions/public/Commands/Get-GitHubOutput.ps1 @@ -28,7 +28,7 @@ Gets the GitHub output and returns a hashtable. #> - [OutputType([pscustomobject])] + [OutputType([hashtable])] [CmdletBinding()] param( # Returns the output as a hashtable. @@ -47,11 +47,22 @@ process { try { + if (-not $Path) { + throw 'The path to the GitHub output file is not set. Please set the path to the GitHub output file using the -Path parameter.' + } + Write-Debug "[$stackPath] - Output path" + Write-Debug $Path if (-not (Test-Path -Path $Path)) { throw "File not found: $Path" } - Get-Content -Path $Path | ConvertFrom-GitHubOutput -AsHashtable:$AsHashtable + $outputContent = Get-Content -Path $Path + if (-not $outputContent) { + return @{} + } + Write-Debug "[$stackPath] - Output content" + Write-Debug $outputContent + $outputContent | ConvertFrom-GitHubOutput -AsHashtable:$AsHashtable } catch { throw $_ } diff --git a/src/functions/public/Commands/Set-GitHubOutput.ps1 b/src/functions/public/Commands/Set-GitHubOutput.ps1 index f3d54d5f2..85b882c67 100644 --- a/src/functions/public/Commands/Set-GitHubOutput.ps1 +++ b/src/functions/public/Commands/Set-GitHubOutput.ps1 @@ -63,13 +63,11 @@ # If the script is running in a GitHub composite action, accumulate the output under the 'result' key, # else append the key-value pair directly. if ($env:PSMODULE_GITHUB_SCRIPT) { - if (-not $outputs.result) { - $outputs.result = @{ - $Name = $Value - } - } else { - $outputs.result[$Name] = $Value + Write-Debug "[$stackPath] - Running in GitHub-Script composite action" + if (-not $outputs.ContainsKey('result')) { + $outputs['result'] = @{} } + $outputs['result'][$Name] = $Value } else { $outputs[$Name] = $Value }