GitHub Actions – new workflow syntax features

The GitHub Actions workflow syntax has new features based on feedback from our community.

Env at the workflow and job level

It is common to need define a set of environment variables that are used in multiple steps in a job and even multiple jobs in a workflow. Now you can add an `env` map at both the workflow and job level. Those environment variables will be merged with the `env` defined at any step lower in the hierarchy.

If at the job level

Many of you have commented that you would like to have jobs that run only under certain conditions just like you can with steps. Now you can define an if as part of a job using the same expressions you can with a step.

jobs:
  job1:
    if: github.event_name == 'pull_request'
    steps:
    - run: echo "Hello in a PR"

Learn more about GitHub Actions workflow syntax

We’ve updated the event filtering syntax for paths, branches and tags to better support common scenarios and address some customer feedback.

In the initial syntax it was not possible to match all files recursively as we did not support the ** glob.

Now you can simply specify a pattern like **/*.js to match all js files in all paths.

on:
  push:
    paths:
    - "**/*.js"

There was also confusion about how to always run except for changes under a certain folder.

Previously you had to first include all files and then negate some paths.

on:
  push:
    paths:
    - "*"
    - "!docs"

Now you can specify `paths-ignore`.

on:
  push:
    paths-ignore:
    - "docs/**"

Learn more about event filtering in GitHub Actions here.

See more