How to Allow Specific Matrix Legs to Fail in GitHub Actions
Drive continue-on-error from a matrix flag so only the experimental legs are allowed to fail without failing the run.
Attach an experimental flag to specific legs via include, then set continue-on-error: ${{ matrix.experimental }} so those legs are soft failures.
Steps
- Add a base matrix, then flag specific legs with
include. - Set
continue-on-error: ${{ matrix.experimental == true }}. - Legs without the flag stay blocking as usual.
Workflow
.github/workflows/ci.yml
jobs:
test:
strategy:
fail-fast: false
matrix:
node: [20, 22]
include:
- node: 23
experimental: true
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental == true }}
steps:
- uses: actions/setup-node@v4
with: { node-version: ${{ matrix.node }} }
- run: npm ci && npm testGotchas
- Legs without the
experimentalkey evaluate the flag as empty, which is treated as false. - Pair with
fail-fast: falseso a soft-failing leg does not cancel healthy siblings.
Related guides
How to Control fail-fast in a GitHub Actions MatrixChoose whether a GitHub Actions matrix stops at the first failing leg or runs every combination to completion…
How to Add Extra Variables Per Matrix Combination in GitHub ActionsAttach extra values to specific GitHub Actions matrix combinations with an include that matches an existing l…