Skip to content
Latchkey

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 test

Gotchas

  • Legs without the experimental key evaluate the flag as empty, which is treated as false.
  • Pair with fail-fast: false so a soft-failing leg does not cancel healthy siblings.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →