Skip to content

Commit

Permalink
Refactor Set-GitHubOutput.ps1 to conditionally convert non-string val…
Browse files Browse the repository at this point in the history
…ues to JSON format within GitHub composite actions
  • Loading branch information
MariusStorhaug committed Feb 25, 2025
1 parent 3d06aee commit e4ff3b8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/functions/public/Commands/Set-GitHubOutput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@
default {}
}

if ($Value -isnot [string]) {
$Value = $Value | ConvertTo-Json -Compress -Depth 100
}

Write-Verbose "Output: [$Name] = [$Value]"

# 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 ($Value -isnot [string]) {
$Value = $Value | ConvertTo-Json -Compress -Depth 100
}
Write-Debug "[$stackPath] - Running in GitHub-Script composite action"
if (-not $outputs.ContainsKey('result')) {
$outputs['result'] = @{}
Expand Down

0 comments on commit e4ff3b8

Please sign in to comment.