Stylianos Gakis
07/04/2025, 2:35 PM- name: This works
run: echo SOME_VAR=asd >> $GITHUB_ENV
- name: Using it
run: echo $SOME_VAR
env:
SOME_VAR: ${{ env.SOME_VAR }}
And this works perfectly fine.
In Kotlin I try to do:
runCommand("echo SOME_VAR=asd >> \$GITHUB_ENV")
(where runCommand comes from here https://github.com/apollographql/apollo-kotlin/blob/65dd7a44a74ed016988777521248da164de32ea0/scripts/bump-kotlin-nightlies.main.kts#L71C1-L85C2 basically using ProcessBuilder
)
And then I try to do the same exact Using it
task, but nothing at all gets printed. The contents of SOME_VAR
are just empty.
Is this some issue with ProcessBuilder, or something I am doing which is wrong here?eStylianos Gakis
07/04/2025, 2:37 PMmbonnin
07/04/2025, 2:38 PMrunCommand()
is not really what I'd call "production ready", this was hacked together quickly 😅Stylianos Gakis
07/04/2025, 2:39 PMmbonnin
07/04/2025, 2:40 PMProcessBuilder
doesn't know about shellmbonnin
07/04/2025, 2:41 PMfun runCommand(args: String): String {
return runCommand(*args.split(" ").toTypedArray())
}
This basically is going to echo ">>"
mbonnin
07/04/2025, 2:41 PMmbonnin
07/04/2025, 2:42 PMSystem.getenv("GITHUB_ENV")
, hope it's a file (I think it should be?) and then append to it with the usual outputStream
mbonnin
07/04/2025, 2:43 PMephemient
07/04/2025, 2:53 PMProcessBuilder(listOf("/bin/sh", "-c", "echo PACKAGE_SWIFT_FILE_CONTENT=asd >> $GITHUB_ENV"))
is equivalent to what https://pubs.opengroup.org/onlinepubs/007904975/functions/system.html doesephemient
07/04/2025, 2:57 PMsh
, but rather
"cmd.exe", "/c", "..."
or maybe
"powershell.exe", "-Command", "..."
Stylianos Gakis
07/04/2025, 3:00 PMPiotr Krzemiński
07/04/2025, 7:01 PM