1. Build matrix
strategy.matrix expands the job across each value in parallel.
strategy:
matrix:Typorithm · medium
Step 1 of 8 · intro card
CI/CD
A build matrix runs a job across several versions in parallel (here Node 20 and 22). Secrets are injected from the encrypted store via the secrets context and never hardcoded. Caching dependencies speeds builds, and the ${{ ... }} expression syntax reads matrix values and secrets.
A build matrix multiplies one job across an axis of values. matrix.node: [20, 22] runs the job twice in parallel — once on Node 20 and once on Node 22 — catching version-specific breakage.
The ${{ ... }} expression syntax reads context values: ${{ matrix.node }} pulls the current matrix value, and ${{ secrets.TOKEN }} pulls a value from the encrypted secrets store. Secrets are never hardcoded in the YAML.
Caching dependencies (often built into actions like setup-node) avoids re-downloading them every run, which speeds builds. For deploys, reusable workflows and OIDC handle secure cloud authentication without long-lived secrets.
matrix runs a job across versions in parallel.
${{ secrets.TOKEN }} injects an encrypted secret.
Caching dependencies avoids re-downloading them each run.
strategy:
matrix:
node: [20, 22]
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- env:
TOKEN: ${{ secrets.TOKEN }}Connect each part of the code to the concept before you type.
strategy.matrix expands the job across each value in parallel.
strategy:
matrix:node lists the versions to test — the job runs once per value.
node: [20, 22]setup-node installs the chosen Node version and can cache dependencies.
- uses: actions/setup-node@v4${{ matrix.node }} reads the current matrix value for this job run.
node-version: ${{ matrix.node }}${{ secrets.TOKEN }} injects an encrypted secret instead of hardcoding it.
TOKEN: ${{ secrets.TOKEN }}Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.