How do I dynamically set an environment variable in a github composite action step?

How do I dynamically set an environment variable in a github composite action step?

The issue youre hitting is that calling echo FOO=${{ github.event.inputs.foo }} >> $GITHUB_ENV in a GitHub Action script steps does not set that variable within the current steps script, if you expand the env header for the next step you should see your dynamically-set environment variable feeding into that step

What I usually do is something like this:

FOO=${{ github.event.inputs.foo }}
echo FOO=${FOO} >> $GITHUB_ENV

So you set a variable called FOO in the current steps script (making it available on subsequent lines in the same step) AND exports it for future steps

How do I dynamically set an environment variable in a github composite action step?

Leave a Reply

Your email address will not be published.