Nested variable substitution #26428
-
I am using a matrix to run my unit tests in a variety of environments. I have a dependencies file per environment. I want to use the hash of this in the cache restore key so I need to define the file to look for using the ${{ matrix.stack }} variable (which is just a string) like so:
The nested expansion of ${{ matrix.stack }} within the hashFiles call doesn’t happen so the key defaults to:
Therefore the cached environment is always restored even when the environment file is changed. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Nested expressions are not supported I think? You can do the following however:
Context and expression syntax for GitHub Actions - GitHub Docs |
Beta Was this translation helpful? Give feedback.
-
Fantastic, that’s worked perfectly. I’d missed the |
Beta Was this translation helpful? Give feedback.
-
this doesn't work for For now I have resorted to a setup job to manipulate the json with |
Beta Was this translation helpful? Give feedback.
Nested expressions are not supported I think?
You can do the following however:
key: ${{ format('{0}-conda-stage-{1}-{2}', runner.os, matrix.stack, hashFiles(format('env/{0}_environment.yml', matrix.stack))) }}
docs.github.com
Context and expression syntax for GitHub Actions - GitHub Docs