nodejs_version and operating_system—while allowing you to exclude specific pairs.
Defining the Matrix
First, we define a matrix with three Node.js versions (18, 19, 20) and two operating systems (ubuntu-latest, macos-latest), excluding the unwanted combination of Node.js 18 on macOS:
At this stage, both
runs-on and node-version are hardcoded. In the next section, we’ll update them to use matrix variables.Matrix Combinations Overview
To visualize which jobs will run, consider this table of all possible combinations:Referencing the Matrix Variables
Replace the hardcoded values with${{ matrix.operating_system }} and ${{ matrix.nodejs_version }} so each job picks up the correct OS and Node.js version:
Commit and Observe the Workflow
Commit your changes with a descriptive message like:


macOS runners often take a bit longer to start. Be patient as those jobs initialize.
Links and References
- GitHub Actions: Using a matrix for your jobs
- actions/checkout
- actions/setup-node
- actions/upload-artifact