---
source: https://iinventedlight.com/library/notes/github-actions-matrix.md
title: "Matrix jobs in GitHub Actions"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (github/docs); prose restates or closely paraphrases cited source lines"
license_family: github-docs-ccby
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Running variations of jobs in a workflow - GitHub Docs, CC BY 4.0 (github/docs); GitHub Docs, Workflow syntax for GitHub Actions - GitHub Docs, CC BY 4.0 (github/docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: GitHub"
tags: ['github', 'actions', 'matrix', 'ci']
sources:
  - id: S1
    title: "Running variations of jobs in a workflow - GitHub Docs"
    publisher: GitHub Docs
    url: https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
    accessed: 2026-11-04
    license: "CC BY 4.0 (github/docs)"
  - id: S2
    title: "Workflow syntax for GitHub Actions - GitHub Docs"
    publisher: GitHub Docs
    url: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
    accessed: 2026-11-04
    license: "CC BY 4.0 (github/docs)"
---
# Matrix jobs in GitHub Actions

**Answer:** Use jobs.<job_id>.strategy.matrix to define a matrix of different job configurations. A job will run for each possible combination of the variables. (S2)

## Shaping the matrix

- Specify multiple variables to create a multi-dimensional matrix. (S2)
- To expand existing matrix configurations or to add new configurations, use jobs.<job_id>.strategy.matrix.include. The value of include is a list of objects. (S1)
- To remove specific configurations defined in the matrix, use jobs.<job_id>.strategy.matrix.exclude. (S1)
- You can use the output from one job to define matrices for multiple jobs. (S1)
- A matrix will generate a maximum of 256 jobs per workflow run, for both GitHub-hosted and self-hosted runners. (S2)

## Running and failures

- To control how job failures are handled, use jobs.<job_id>.strategy.fail-fast and jobs.<job_id>.continue-on-error. (S1)
- To set the maximum number of jobs that can run simultaneously when using a matrix job strategy, use jobs.<job_id>.strategy.max-parallel. (S1)
- You can allow specific jobs in a job matrix to fail without failing the workflow run. (S2)
- The jobs.<job_id>.if condition is evaluated before jobs.<job_id>.strategy.matrix is applied. (S2)
- Actions does not guarantee the order that matrix jobs will run in. (S2)

## Claims
- id: C1
  claim: A matrix job runs once per combination of variables.
  source: S2
  evidence: "A job will run for each possible combination of the variables."
- id: C2
  claim: include adds or expands matrix configurations.
  source: S1
  evidence: "The value of include is a list of objects."
- id: C3
  claim: A matrix generates at most 256 jobs per run.
  source: S2
  evidence: "A matrix will generate a maximum of 256 jobs per workflow run."
- id: C4
  claim: The job if condition is evaluated before the matrix is applied.
  source: S2
  evidence: "The jobs.<job_id>.if condition is evaluated before jobs.<job_id>.strategy.matrix is applied."

## Sources
- [S1] Running variations of jobs in a workflow - GitHub Docs. GitHub Docs. https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow . License: CC BY 4.0 (github/docs). Accessed 2026-11-04.
- [S2] Workflow syntax for GitHub Actions - GitHub Docs. GitHub Docs. https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax . License: CC BY 4.0 (github/docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
