Skip to main content

Expressions

You can evaluate expressions in workflows and actions.

About expressions

You can use expressions to programmatically set environment variables in workflow files and access contexts. An expression can be any combination of literal values, references to a context, or functions. You can combine literals, context references, and functions using operators. For more information about contexts, see Contexts reference.

Expressions are commonly used with the conditional if keyword in a workflow file to determine whether a step should run. When an if conditional is true, the step will run.

Debes usar una sintaxis específica para decirle a GitHub que evalúe una expresión en lugar de tratarla como una cadena.

${{ <expression> }}

Nota:

The exception to this rule is when you are using expressions in an if clause, where, optionally, you can usually omit ${{ and }}. For more information about if conditionals, see Sintaxis del flujo de trabajo para GitHub Actions.

Advertencia

Al crear flujos de trabajo y acciones, siempre debe tener en cuenta si el código podría ejecutar una entrada de posibles atacantes que no es de confianza. Se tratará a algunos contextos como una entrada no confiable, ya que un atacante podrían insertar su propio contenido malintencionado. Para más información, consulta Fortalecimiento de seguridad para GitHub Actions.

Example setting an environment variable

env:
  MY_ENV_VAR: ${{ <expression> }}

Further reading

For technical reference information about expressions you can use in workflows and actions, see Evaluación de expresiones en flujos de trabajo y acciones.