GitHub Actions defaults setting

Viewed 2786

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?

1 Answers

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.

Related