Question about expression context parsing #26337
-
This might be the dumbest question ever… What contexts in a workflow is it possible to use MYVAR and when it is required to use {{ env.MYVAR }} ? I can’t find any documentation on this. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
also as a followup, is it possible to create a workflow level environment variable using bash to evaluate something dynamically? |
Beta Was this translation helpful? Give feedback.
-
And for creating environment variables, see Setting an environment variable. 😉 In short, you can do something like
which writes the variable to a special file, and the Actions runner makes sure it’s available in subsequent steps. And you can of course build that definition dynamically. |
Beta Was this translation helpful? Give feedback.
-
Thanks! I wasn’t sure if For the second question, I’m talking about trying to set a workflow level env variable using bash. |
Beta Was this translation helpful? Give feedback.
-
There’s no equivalent at the workflow level. The syntax I mentioned above works at the job level, for all steps after the one setting the variable. If you want to transfer data between jobs look at outputs, or possibly artifacts. |
Beta Was this translation helpful? Give feedback.
-
Thanks, too bad. I guess I’ll have to create a feature request for that! |
Beta Was this translation helpful? Give feedback.
$MYVAR
is Bash (and generally Unix shell) syntax.${{ env.MYVAR }}
is Github actions syntax. So you can use the former wherever you have a shell, which is in therun
part of steps (unless you set another interpreter, or run on Windows).And for creating environment variables, see Setting an environment variable. 😉 In short, you can do something like
which writes the variable to a special file, and the Actions runner makes sure it’s available in subsequent steps. And you can of course build that definition dynamically.