diff --git a/src/GitHubActions.jl b/src/GitHubActions.jl index 1fb2e4f..70331ed 100644 --- a/src/GitHubActions.jl +++ b/src/GitHubActions.jl @@ -116,7 +116,7 @@ log_warning(msg) = command("warning", (), msg) Save value `v` with name `k` to state. """ -save_state(k, v) = command("save-state", (name=k,), v) +save_state(k, v) = add_to_file("GITHUB_STATE", "$k=$v") """ set_command_echo(enable) @@ -130,7 +130,7 @@ set_command_echo(enable) = command("echo", (), enable ? "on" : "off") Set the output with name `k` to value `v`. """ -set_output(k, v) = command("set-output", (name=k,), v) +set_output(k, v) = add_to_file("GITHUB_OUTPUT", "$k=$v") """ set_secret(v) diff --git a/test/runtests.jl b/test/runtests.jl index d0bc5eb..d09e182 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -27,12 +27,22 @@ const GHA = GitHubActions @test (@capture_out log_error("a")) == "::error::a\n" @test (@capture_out log_warning("a")) == "::warning::a\n" - @test (@capture_out save_state("a", "b")) == "::save-state name=a::b\n" + mktemp() do file, io + withenv("GITHUB_STATE" => file) do + save_state("a", "b") + @test read(file, String) == "a=b\n" + end + end @test (@capture_out set_command_echo(true)) == "::echo::on\n" @test (@capture_out set_command_echo(false)) == "::echo::off\n" - @test (@capture_out set_output("a", "b")) == "::set-output name=a::b\n" + mktemp() do file, io + withenv("GITHUB_OUTPUT" => file) do + set_output("a", "b") + @test read(file, String) == "a=b\n" + end + end @test (@capture_out set_secret("a")) == "::add-mask::a\n"