Understanding contexts, environment variables, and expressions
Some of the workflow examples we've shared throughout this book have included expressions, contexts, and environment variables. This section will provide more details about each.
Contexts
You can use contexts to access information about steps, workflow runs, jobs, and runner environments. Any time you want to access a context from within a workflow file, you need to use a syntax similar to ${{ <context-goes-here> }}
. The following example shows how to access the steps
context:
tag_name: ${{ steps.gets_project_name.outputs.project_name }}
Contexts can be used mostly anywhere in your workflow file. They are often used with expressions to check for specific conditions. The following example uses the if
statement to validate the github
context. In this case, the job will only run if the result of the expression is approved
:
if: github.event_name == 'pull_request_review' && github...