8

Official github actions documentation says I can set the defaults to specfify defaults settings for all jobs (https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#defaults). I want to set that up to specify

defaults:
  runs-on: ubuntu-latest
  strategy:
    fail-fast: false # do not cancel 7.2 if 7.3 fails
    matrix:
      php: ['7.2', '7.3', '7.4']
      node-version: ['12.5']
jobs:
    ...

But this fails with

The workflow is not valid. .github/workflows/code_checks.yaml (Line: 7, Col: 3): Unexpected value 'runs-on',.github/workflows/code_checks.yaml (Line: 8, Col: 3): Unexpected value 'strategy'

I want to specify the same runs-on and strategy for all my jobs. Why isn't the defaults working?

Ivo Valchev
  • 215
  • 3
  • 11

1 Answers1

8

This is not possible, with defaults you can only set the shell and working-directory.

You're kinda looking for default-strategy which doesn't exist. One thing to keep in mind with Github Actions is that each job is spawned on a different machine which doesn't share any information with the previous job.

What suits your needs better is to create one job with one set of strategies and multiple steps.

zzarbi
  • 1,832
  • 3
  • 15
  • 29
  • 1
    Yes, but that way I can't execute the tests and checks in parallel, which is a huge benefit of Github Actions, right? – Ivo Valchev May 17 '20 at 09:57
  • 1
    If you set a matrix on 1 job, that 1 one job will be run in parallel on our matrix. A Job can have has many steps as you want. – zzarbi May 17 '20 at 17:05