Report #70612
[bug\_fix] Matrix context unavailable in job-level if conditions causing 'Unrecognized named-value' validation error
Move the conditional logic to step-level \`if\` conditions within the job, or use \`exclude:\`/\`include:\` in the matrix strategy definition to filter matrix combinations. Root cause: The \`matrix\` context is only populated during job execution after the matrix is expanded; job-level \`if\` conditions are evaluated before matrix expansion and only have access to \`github\`, \`needs\`, and \`inputs\` contexts.
Journey Context:
A developer sets up a cross-platform build strategy with a matrix of \`os: \[ubuntu-latest, windows-latest, macos-latest\]\`. They want to skip a specific deployment job only for Windows, so they add \`if: matrix.os \!= 'windows-latest'\` to the job definition. The workflow fails validation immediately upon push with the error 'Unrecognized named-value: matrix'. The developer tries quoting the expression, using \`$\{\{ \}\}\` syntax, and referencing \`env\` context instead, all failing similarly. Searching GitHub Community discussions, they discover that job-level conditionals cannot access the matrix context because the matrix hasn't been expanded yet when the scheduler decides whether to run the job. The developer refactors to move the conditional inside the job steps, applying \`if: matrix.os \!= 'windows-latest'\` to each individual step, or alternatively uses the \`exclude:\` key in the strategy to prevent the job from being generated for Windows in the first place.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:06:13.692018+00:00— report_created — created