DevOps / GitHub Actions Interview Questions
What are the key GitHub Actions expression contexts and what information does each provide?
Contexts are namespaced objects available inside ${{ }} expressions throughout a workflow. Each context exposes a different slice of information about the run, the repository, or the execution environment.
| Context | Key properties | Example use |
|---|---|---|
github |
ref, sha, event_name, actor, repository, run_id, workflow |
if: github.ref == 'refs/heads/main' |
env |
All environment variables set via env: at any scope |
${{ env.APP_VERSION }} |
secrets |
Encrypted secrets from repo/org/environment settings | ${{ secrets.AWS_SECRET_KEY }} |
vars |
Non-sensitive configuration variables from settings | ${{ vars.TARGET_ENV }} |
runner |
os, arch, temp, tool_cache |
key: ${{ runner.os }}-npm-... |
job |
status (success/failure/cancelled) |
if: job.status == 'failure' |
steps |
steps.<id>.outputs, steps.<id>.outcome |
${{ steps.build.outputs.version }} |
needs |
needs.<job>.result, needs.<job>.outputs |
${{ needs.build.outputs.artifact-name }} |
matrix |
Current matrix variables for this job instance | ${{ matrix.node }} |
inputs |
Inputs passed via workflow_dispatch or workflow_call |
${{ inputs.environment }} |
Context availability varies by event. For example, github.event.pull_request is only populated on pull_request events, and needs is only available in jobs that declare needs:. Referencing an undefined context key returns an empty string rather than an error.
More Related questions...