Interview Prep/GitHub Actions/Jobs, Steps, Matrix & Concurrency

How do `include` and `exclude` work in a matrix?

IntermediateConceptJobs, Steps, Matrix & Concurrency
Answer

exclude removes combinations matching all listed keys. include either adds keys to existing combinations that match (without overwriting original values) or, if it matches none, adds a new standalone combination. Exclusions are processed before inclusions.

matrix:
  os: [ubuntu-24.04, windows-2025]
  node: [20, 22]
  exclude:
    - { os: windows-2025, node: 20 }
  include:
    - { node: 22, coverage: true }          # adds coverage to both node 22 legs
    - { os: macos-15, node: 22 }            # new extra leg
All GitHub Actions questions Roadmap: GitHub Actions

More on Jobs, Steps, Matrix & Concurrency