how to set action env variables within a shell script? #27127
-
I’ve got a bash script that forms a bunch of env variables used to tag build artifacts. How do I export these variables from the shell script into the action build variables? (EDITED) actually running echo “::set-env name=VERSION_TAG::$VERSION_TAG” within the shell script does does translate into an action variable. I’ve built a test bed that does work :slight_smile: |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Hi @andy-brainome , The set-env command will add environment variable to all the following steps in the current job. What’s your meaning of “action build variables” ? If you want to use the env in action’s input under with section, you could use ${{ env.VERSION_TAG }} to get the value of it. For example:
|
Beta Was this translation helpful? Give feedback.
-
My issue is with exporting env variables from within a shell script into action env variables. I tried using the echo “::set-env…” from within the shell script without success - I suspect ::set-env does not trigger the action from registering env variables pseudocode e.g. calc-version.sh
build-docker.yml
|
Beta Was this translation helpful? Give feedback.
-
You should access your env vars like this
I guess that I think that the following syntax |
Beta Was this translation helpful? Give feedback.
-
I tried add set-env command in bash scripts calc-version.sh :
My workflow is :
Both invoke env variable syntax could work: VERSION and {{env.VERSION }} Can you try again? |
Beta Was this translation helpful? Give feedback.
-
Thanks for documenting this. It pointed me in the right direction. Workflow commands for GitHub Actions - GitHub Docs//docs.github.com/en/actions/reference/workflow-commands-for-github-actions |
Beta Was this translation helpful? Give feedback.
Hi @andy-brainome ,
The set-env command will add environment variable to all the following steps in the current job.
What’s your meaning of “action build variables” ? If you want to use the env in action’s input under with section, you could use
${{ env.VERSION_TAG }} to get the value of it. For example: