Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions "on push" trigger - "path" argument not working with patterns/wildcards

My GitHub Action is set up to be triggered on push. It works fine when I don't use a path: argument (or I hardcode file paths in it), but it does not work if I use a pattern or wildcard.

Here is the relative portion of my Action:

name: "Publish YAML files"
on: 
  push:
    branches: 
      - master
      - main-github-test
    paths:
      - '**.yaml'
      - '**.yml'

The expectation is that my Action will get triggered whenever any file in my repository with the .yaml or .yml extension is modified and pushed to either or the two specified branches. My assumption is that this wildcard searches recursively throughout my repository from the root to the bottom.

But this is not happening.

If I hardcode specific paths (e.g. docs/myfile.yml), it works fine. But somehow it doesn't like my pattern/wildcard, even though I'm doing everything "the right way" according to GitHub's own documentation (see this).

What am I doing wrong?

What I tried:

  • The following paths: argument in my Action:
    paths:
      - '**.yaml'
      - '**.yml'

Expected behavior:

  • My Action is triggered whenever a .yaml or .yml file is modified/committed/pushed to the specified branches.

Actual behavior.

  • Action is not triggered. Instead I must use hardcoded paths or omit the paths: argument entirely.
like image 322
CB_at_Sw Avatar asked Jul 23 '26 22:07

CB_at_Sw


1 Answers

Please try this

name: "Publish YAML files"
on: 
  push:
    branches: 
      - master
      - main-github-test
    paths:
      - '**/*.yaml'
      - '**/*.yml'

It will catch all yaml and yml files.

You can read about globbing here

like image 137
Krzysztof Madej Avatar answered Jul 25 '26 11:07

Krzysztof Madej



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!