Action triggered not according to `on`

We use github actions pretty extensively, and have a lot of workflows defined. Occasionally it seems that actions are triggered regardless of the filtering rules defined in the workflow.

For example, with the following on clause the workflow at .github/workflows/docs.yml:

on:
  push:
    paths:
      - 'docs/**'

Was triggered even though in the branch only the following files are changed:

.github/workflows/license-check.yml
scripts/license_check.py

In the same instance, a bunch of other workflows were triggered when they should not have. More examples of on clauses:

on:
  push:
    paths:
      - '**.md'
---
on:
  push:
    paths:
      - '**.go'
      - 'go.mod'
      - 'go.sum'
---
on:
  push:
    paths:
      - '**.pb.go'
      - '**.proto'

I think that all of our workflows that have paths filters were triggered. Maybe I don’t quite understand the logic causing the trigger.

Could rebasing the branch have anything to do with it?

Thanks!

Definitely possible, but it depends on what was changed in the rebase. E.g. if you rebase a dev branch on top of default branch changes which match the path filter those are new changes in the dev branch. And of course any commit on the dev branch that was rebased is a new commit, even if the same diff was present before.

Ok, cool! Looking at reflog, indeed a ton of files were changed in the default branch between the original base and the new one.

So the Github Actions file set logic is:

  • If the branch didn’t previously exist, changed files in the branch
  • If the branch did previously exist, changed files between the new branch and the old one, using something like git diff --stat?

Thanks!

This is what the documentation says about exactly how the diff for the path filter is calculated:

It don’t have any information beyond that (and experience) either.