Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multiline outputs #11

Merged
merged 1 commit into from Mar 24, 2023
Merged

fix multiline outputs #11

merged 1 commit into from Mar 24, 2023

Conversation

alexrashed
Copy link
Contributor

This PR reverts a small change introduced with 84f77c4 where setting the action's output has been changed from using @actions/core's setOutput function to writing the output to process.env.GITHUB_OUTPUT:

fs.writeFileSync(process.env.GITHUB_OUTPUT, `value=${resultValue}\n`)

This is exactly how it's described in GitHub's blog announcing the deprecation: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

However, this does not work for multiline outputs, as they now fail with an error similar to this:

...
Run mad9000/actions-find-and-replace-string@3
##[debug]Node Action run completed with exit code 0
##[debug]Set output value = <first-output-line>
Error: Unable to process file command 'output' successfully.
Error: Invalid format '<second-output-line>'
##[debug]System.Exception: Invalid format '<second-output-line>'
##[debug]   at GitHub.Runner.Worker.EnvFileKeyValuePairs.GetEnumerator()+MoveNext()
##[debug]   at GitHub.Runner.Worker.SetOutputFileCommand.ProcessCommand(IExecutionContext context, String filePath, ContainerInfo container)
##[debug]   at GitHub.Runner.Worker.FileCommandManager.ProcessFiles(IExecutionContext context, ContainerInfo container)
##[debug]Finishing: <workflow-step-name>
...

In fact, the @action/core library provided by GitHub has been updated a few days before the deprecation was announced such that setOutput uses the new file-based mechanism (and correctly handles multi-line outputs by using an EOF-delimiter based approach): actions/toolkit#1178
This change is contained in @action/core==1.10.0, which is already being used by this action.

Long story short: This PR reverts this change to use setOutput provided by @actions/core again, which should fix issues with multi-line outputs.

@kishyr kishyr merged commit c49c774 into mad9000:main Mar 24, 2023
@alexrashed alexrashed deleted the patch-1 branch March 27, 2023 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants