Git & GitHub Interview Question #109
What are expressions and contexts in GitHub Actions?
Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced
Quick Interview Answer
Expressions use the ${{ ... }} syntax to evaluate workflow data. Contexts expose structured information about the workflow run, repository, event, matrix, jobs, steps, variables, secrets, and other supported values.
Detailed Explanation
Expressions use the ${{ ... }} syntax to evaluate workflow data. Contexts expose structured information about the workflow run, repository, event, matrix, jobs, steps, variables, secrets, and other supported values.
Expressions can control conditions, inputs, environment values, or dynamic configuration. Sensitive values should not be exposed through logging or untrusted expressions.
Code Example
steps:
- name: Run only on main
if: ${{ github.ref == 'refs/heads/main' }}
run: echo "Running on main"
- run: echo "Repository: ${{ github.repository }}"