From 8ed64a16a607d3c25601a1a9983786e76fdd6585 Mon Sep 17 00:00:00 2001 From: Sascha Mann Date: Thu, 13 Jul 2023 10:52:59 +0200 Subject: [PATCH] Enable multiline outputs (#32) Simply copying set_env for now. Fixes #31 --- src/GitHubActions.jl | 9 ++++++++- test/runtests.jl | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/GitHubActions.jl b/src/GitHubActions.jl index b2b5634..4acf6a5 100644 --- a/src/GitHubActions.jl +++ b/src/GitHubActions.jl @@ -130,7 +130,14 @@ set_command_echo(enable) = command("echo", (), enable ? "on" : "off") Set the output with name `k` to value `v`. """ -set_output(k, v) = add_to_file("GITHUB_OUTPUT", "$k=$v") +function set_output(k, v) + val = cmd_value(v) + delimiter = "EOF" + while occursin(delimiter, val) + delimiter *= "EOF" + end + add_to_file("GITHUB_OUTPUT", join(["$k<<$delimiter", val, delimiter], "\n")) +end """ set_secret(v) diff --git a/test/runtests.jl b/test/runtests.jl index d09e182..741f98b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,9 +38,16 @@ const GHA = GitHubActions @test (@capture_out set_command_echo(false)) == "::echo::off\n" mktemp() do file, io - withenv("GITHUB_OUTPUT" => file) do + withenv("GITHUB_OUTPUT" => file, map(c -> string(c) => nothing, 'a':'z')...) do set_output("a", "b") - @test read(file, String) == "a=b\n" + @test read(file, String) == "a<