Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 4

Support saving environment variables between steps

Solved! Go to Solution.

With solved, the only thing standing in the way of reusing a lot of commands between Linux/MacOS and Windows when building C++ with CMake is an option to keep environment variables between steps (currently the environment is reset after each step).


For example, an option `transfer-env` that, when enabled, saves the environment after each step and restores it in the next step would allow me to remove a lot of duplicate code from reproc's ( and doctest's WIP ( Github Actions configs.


I've seen that it's possible to set global environment variables with `exportVariable` in which makes me think that adding this is possible. If possible I'd try to implement it myself but I do not think the relevant code is open source.

3 Replies
GitHub Staff
Message 2 of 4

Re: Support saving environment variables between steps

You can echo out a string that will set an env for the rest of the job, this is exactly what the toolkit method will do.


echo ::set-env name=action_state::yellow

Pilot Lvl 1
Message 3 of 4

Re: Support saving environment variables between steps

Using set-env I was able to achieve the desired result.


On Windows, VS related environment variables are set by a third-party batch script, so I had to add them with set-env manually after calling the batch script. Instead of filtering the relevant environment variables, I just make every environment variable global using set-env. The script can be found here.

GitHub Staff
Message 4 of 4

Re: Support saving environment variables between steps

Thanks for creating that script.  I would be a little careful with that script as you are stomping on PATH rather an updating it with append-path.  In most cases it probably won't be an issue but you never know.