-
When passing data via the env as a string, the context is expanded, but if the env variable is populated via a file output, the context is not expanded. this example below works fine
but if changed to the one below, it doesn’t work
the first scenario described above outputs
the second scenario outputs
How can I achieve the same results by passing the string as a “parameter”? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
According to the logs , when you set the json content with context directly as the output variable value, it could be evaluated. But when you use $(cat template.json) , it could only evaluate this cat command. It will not continue evaluate the json file content. I would recommend you using sed to replace the value in json file, the context could expand in bash scripts. And then you cat json file content. Please see my code snippet :
|
Beta Was this translation helpful? Give feedback.
-
Thanks @yanjingzhu for the detailed response, it was really helpful. Seeing that the expansion is essentially a format() call, I used that idea to substitute in the placeholders.
The json needed to be escaped in order for format() to work as per the docs, so it ended up looking like this
I think it might be better using sed to escape the curly braces in a json automatically and using format() for the substitution How were you able to see the debug info?, it is quite handy for knowing what is happening under the hood. |
Beta Was this translation helpful? Give feedback.
-
@Ajibola You could also enable step debug logging for your repo by adding Please refer to this document: https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#enabling-step-debug-logging |
Beta Was this translation helpful? Give feedback.
Thanks @yanjingzhu for the detailed response, it was really helpful. Seeing that the expansion is essentially a format() call, I used that idea to substitute in the placeholders.
The json needed to be escaped in order for format() to work as per the docs, so it ended up looking like this
I think it might be better using sed to escape the curly braces in a json automatically and using format() for the substitution
How were you able to see the debug info?, it is quite handy for knowing what is happening under the hood.