Which 'env:' scope takes precedence when the same variable name is defined at workflow, job, and step levels?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Like CSS specificity, the most specific scope wins — step level beats job level beats workflow level when the same var name collides.
Full explanation below image
Full Explanation
GitHub Actions 'env:' blocks have a specificity hierarchy: step-level env: overrides job-level env:, which overrides workflow-level env:. This allows you to set sensible defaults at the workflow level and override them for specific jobs or steps. For example, set 'LOG_LEVEL: info' at workflow level, override to 'LOG_LEVEL: debug' for a specific debugging job, and further override to 'LOG_LEVEL: warn' for a specific noisy step. This mirrors how CSS specificity or Python variable scoping works — the innermost (most specific) definition wins.