Github actions: Using GITHUB_ENV to share data between steps

github share variable environment variable

1 min read | by Jordi Prats

If we want to share data between steps (on a Github action) it's just not enough to export a variable like this:

export VARIABLE_NAME

To be able to share data between steps we'll need to use GITHUB_ENV like so:

echo "VARIABLE_NAME=VALUE" >> $GITHUB_ENV

So, assuming we want to export the contents of $VARIABLE_NAME we can push the variable and it's value using the following command:

echo "VARIABLE_NAME=$VARIABLE_NAME" >> $GITHUB_ENV

Using set-env have been deprecated for a while now, exporting data using GITHUB_ENV is the new way to go


Posted on 05/10/2021