Use matrix context in job context if

I get

Unrecognized named-value: 'matrix'.

when I do this:

 apply_changes:
    if: needs.plan_changes.outputs[format('{0}-changes', matrix.env)] != 'null'
    name: "Apply changes"
    strategy:
      matrix:
        include:
          - env: "dev"
            id: "1"
          - env: "beta"
            id: "1"
    environment:
      name: ${{ matrix.env }}
    needs: [plan_changes]
    runs-on: [self-hosted,live]
    steps:
    - name: Test
      run: |
        echo "${{ format('needs.plan_changes.outputs[{0}-changes',matrix.env)] }}"

Is a job context if not able to use a matrix context? If so, what is a workaround I could use?
There are a lot of envs so duplicting them all in separate jobs is unmanageable.

Many thanks

1 Like

It looks like you can use the matrix context inside of a step (e.g., in the “Test” step).