Excluding paths doesn't work without includes

If I have in paths excludes only, it will not work:

on:
  push:
    paths:
    - '!sub-project/docs/**'

What I suppose is to trigger workflow on all changes but sub-project/docs/. What I get is triggering on any changes

It either should be fixed, or some doc updates is required.

If it’s fixed, then paths-ignore option would not needed IMO.

As for docs, some updates could be done here: https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#excluding-paths
It currently has:

# Excluding paths

You can exclude paths using two types of filters. You cannot use both of these filters for the same event in a workflow.

** paths-ignore - Use the paths-ignore filter when you only need to exclude path names.
** paths - Use the paths filter when you need to filter paths for positive matches and exclude paths.

It should be stressed somehow that using excluds only in paths will not work

1 Like

I agree that the documentation should be more clear. In practice you can work around the limitation by having a blanket include and then exclude the parts you want:

on:
  push:
    paths:
      - '**'
      - '!sub-project/docs/**'
1 Like

That’s exactly what I did. Somehow I didn’t try paths-ignore when I found out the problem and end up with using `- ‘*/**’``

I have created an internal ticket asking document team to update the document . Thank you for pointing this out and it is helpful to make a better GitHub Actions.

1 Like