Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Matrix (env vars)

  • matrix

  • strategy

  • fail-fast

  • matrix

name: Matrix environment variables

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        fruit:
          - Apple
          - Banana
        meal:
          - Breakfast
          - Lunch
    steps:
    - name: Single step
      env:
         DEMO_FRUIT: ${{ matrix.fruit }}
         DEMO_MEAL:  ${{ matrix.meal }}
      run: |
        echo $DEMO_FRUIT for $DEMO_MEAL

  • Create a matrix of configuration options to run the jobs. (e.g. on different operating systesm, different versions of the compiler, etc.)

  • fail-fast: What should happen when one of the cases fails? Should all run to completion or should we stop all the jobs if one already failed?