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.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateWhat are reusable workflows and how do you call one?Intermediate