DevOps / GitHub Actions Interview Questions
What is the difference between the env:, secrets:, and vars: contexts in GitHub Actions?
All three hold key-value configuration but differ in storage location, security characteristics, and intended use.
| Context | Where it is defined | Encrypted at rest? | Visible in logs? | Typical use |
|---|---|---|---|---|
env: |
Inline in the workflow YAML (workflow/job/step scope) | No — plain text in the repo | Yes | Non-sensitive config like feature flags, version numbers, region names embedded directly in YAML |
secrets: |
Repository / Organisation / Environment Settings → Secrets | Yes — encrypted by GitHub | No — masked as *** |
Passwords, API keys, tokens, certificates — anything that must not be readable in the YAML or logs |
vars: |
Repository / Organisation / Environment Settings → Variables | No — stored as plain text | Yes | Non-sensitive config that should be managed in the GitHub UI without editing YAML (e.g. target environment URL, Node version to use across many workflows) |
The key distinction between env: and vars: is that vars: are managed in the GitHub UI and shared across workflows without touching YAML files, whereas env: values are hardcoded in the YAML itself. Use vars: when you want non-engineers to be able to change configuration without a pull request.
Access syntax: ${{ secrets.MY_KEY }}, ${{ vars.MY_VAR }}, ${{ env.MY_ENV }}.
More Related questions...