Amadevus / pwsh-script

GitHub Action to run PowerShell scripts in a rich, prepared scope - inspired by actions/github-script.
MIT License
47 stars 8 forks source link

Failing Set-ActionOutput when value is multi-line #17

Closed amis92 closed 1 year ago

amis92 commented 1 year ago

Setting output fails when using environment files and passing a multi-line value.

image

https://github.com/Amadevus/pwsh-script/actions/runs/3276636531/jobs/5392922719#step:11:13

Error: Unable to process file command 'output' successfully.
Error: Invalid format ' new line '
amis92 commented 1 year ago

Turns out, the implementation incorrectly decides to use key=value format. When newline in value is detected, it should instead use the key<<delimiterLFvalueLFdelimiter format.

However, the PowerShell implementation of ConvertTo-ActionKeyValueFileCommand makes an incorrect comparison to find whether value has newlines: ($convertedValue -contains "n")will return true only if value *is* a single newline, because-contains` is a collection operator, not a string operator.

amis92 commented 1 year ago

Bug is in version 2.0.2 of this action.