Interview Prep/CI/CD/GitHub Actions

How does a build matrix work?

IntermediateConceptGitHub Actions
Answer

strategy.matrix expands one job definition into multiple jobs across combinations of variables, such as OS and language version. include adds or extends combinations, exclude removes some, fail-fast: false keeps other jobs running when one fails, and max-parallel limits concurrency.

strategy:
  fail-fast: false
  matrix:
    os: [ubuntu-latest, windows-latest]
    node: [20, 22]
    exclude:
      - { os: windows-latest, node: 20 }
runs-on: ${{ matrix.os }}
steps:
  - uses: actions/setup-node@v4
    with: { node-version: '${{ matrix.node }}' }

A matrix can generate at most 256 jobs per workflow run.

All CI/CD questions

More on GitHub Actions