Skip to content

Merge per job env variables with job variables from matrix strategy

ChristopherHX edited this page Nov 10, 2022 · 1 revision

You may want to be able to specify some env variables for all jobs, but some configurations needs additional env variables

on: push
jobs:
  _:
    strategy:
      matrix:
        os:
        - ubuntu-latest
        - macos-latest
        include:
        - os: ubuntu-latest # Only ubuntu-latest has an extra env var MYVAR
          env:
            MYVAR: myval
    env:
      SOME_ENV: B
      ${{ insert }}: ${{ matrix.env || fromjson('{}') }}
    runs-on: ${{ matrix.os }}
    steps:
    - run: env