It can be confusing. Their official documentation is a big fragmented.

Here are some tips:

  1. Things in double curly braces like ${{ matrix.name }} are called “contexts or expressions” and can be used to get, set, or perform simple operations.
  2. You can omit the double curly braces in if conitions, as the whole condition is evaluated as an expression: if: contains(github.ref, 'tags/v')
  3. You can set variables for the whole workflow to use in “env”
  4. Reading those variables is done with the env context when you are inside a with, name, or if: ${{ env.SOME_VARIABLE }}
  5. Inside of run, you have access to bash ENV variables in addition to contexts/expressions. That means $SOME_VARIABLE or ${SOME_VARIABLE} will work but only when using bash and not while using powershell on windows. The version with curly braces (variable expansion) is often used when the variable is forming part of a larger string to avoid ambiguity.

ENV variables must set properly in the workflow/job/step before you use it. If you need the variable to be os-agnostic, use the env context.


Leave a Reply

Your email address will not be published. Required fields are marked *