Set ENV Variable Using Github Action Workflow CMD #25993
-
Hi There i am currently working on a simple github action for my personal use in which i need to set some ENV Variable on the go. (Fully Dynamic) and if its a simple string it works great when i use
but thats not the case here i need to create below YAML Env content dynamically using PHP
in the above example you can see i have used | to enter multi line values. As of now using PHP i was able to set variables if its a single line values Example
but if i try like this
My other action is able to read only the | not the full string 😦 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you use the “set-env” command to set an environment variable with multi-line value, you need to escape the characters ‘%’, ‘\n’ and ‘\r’ in the value before passing it to the new environment variable. The runner will unescape in reverse.
|
Beta Was this translation helpful? Give feedback.
@varunsridharan,
If you use the “set-env” command to set an environment variable with multi-line value, you need to escape the characters ‘%’, ‘\n’ and ‘\r’ in the value before passing it to the new environment variable. The runner will unescape in reverse.
A simple demo as reference:
name: print env
shell: bash
run: echo "$MY_ENV"