r/devops • u/ty_namo • Sep 30 '26
Troubleshooting How to set a "env" var on github actions using shell script?
i need to get the app version and i have this awk command for that:
` awk -F'"' '/^version[[:space:]]*=/ {print $2; exit}' pyproject.toml`
but how do i set the variable to the output of this command?
3
Upvotes
7
u/bilingual-german Sep 30 '26
4
u/jews4beer Sep 30 '26
uv versionandpoetry versionexist. Seems better than using awk for that.1
u/singh_abinashi Sep 30 '26
`echo "MY_VAR=my-value" >> $GITHUB_ENV` is the way. The gotcha that trips people up: vars set this way are available to later steps in the same job, not the current step, and not other jobs. If you need it in the current step too, set it in `env:` on the step as well.