Capture An Output Value For Use In A Later Step
GitHub Actions has a workflow command called set-output
. This can be used to capture the output from a shell command in step. That output value can then be used in a later step.
A useful example of this is reading the version of a tool from a dot-file to tell a later step what version of that tool to install.
Here's the .tool-versions
file included in my repository:
Assuming I've already checked out my repo, I can find and read the nodejs
version from my .tool-versions
file with a step that uses set-output
.
echo
runs the command in the string which sets NODE_VERSION
as an output value to what ends up being 15.4.0
.
This output value can be referenced in a later step.
steps
has a reference to the nodejs
step (note the id
above) which then has outputs
like the NODE_VERSION
.
Last updated