3

I have the following Github workflow file:

name: test-ci2

on:
  push:
    branches: [ '**/ci-*' ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Triggered by **/ci-* pattern"

This is triggered when I push the branch mjd/try-claude-in-ci-20251216. I don't understand why, since it ought to match only a branch name containing /ci-.

screencap of Github action run showing that the branchname is as I said

I have read the Github documentation for this, but my reading doesn't explain why this branch should match this pattern. None of the examples is on point.

A bug? Or have I misunderstood something?

4
  • Please don't post textual information in the form of pictures. Please see: Why should I not upload images of code/data/errors? If you still need an image, it can complement the textual information. Commented Dec 17, 2025 at 0:50
  • I don't need the image; it merely illustrates the situation that I described in detail in the previous paragraph. Commented Dec 17, 2025 at 0:53
  • If you don't need the image, why have you inserted https://i.sstatic.net/71H3pYeK.png? Commented Dec 17, 2025 at 0:54
  • 3
    As an enhancement beyond what is absolutely necessary. Commented Dec 17, 2025 at 0:57

1 Answer 1

1

As far as I can tell, github is matching ** as anything (as per docs), but discarding the slash completely.

    # matches:
    # - testing/this-should-not-be-ci-run
    # - testing/ci-test
    # - this-is-not-a-ci-run
    # - superci-lious
    # - ci-cmon-github-wtf
    # - testing/multiple/levels/wut-ci-wut
    # - abci-wut
    # - ci--wut
    # - ci-
    #
    # does not match:
    # - testing/this-is-ridicilous
    # - supercilious
    # - testing/citest
    # - CI-upper
    # - testing/ci-/wut
    branches: ["**/ci-*"]

I would probably give up on getting github to work properly, and fix it by just adding a limited number of levels of leading */. In quick testing, this works to do what you want:

    # matches:
    # - testing/ci-this-should-match
    # - testing/two/levels/ci-please
    #
    # does not match:
    # - testing/does-ci-still-match
    # - this-is-stil-not-a-ci-run
    branches: ["*/ci-*", "*/*/ci-*", "*/*/*/ci-*"]

Definitely seems like a bug to me

edit:

I've verified that minimatch and bash (with globstar enabled) will not match a pattern **/test-* to something/inner-test-case

Both of them do (surprisingly to me) match **/test-* to test-something

Sign up to request clarification or add additional context in comments.

1 Comment

I verified that minimatch and bash do not match globstar this way, and filed a discussion on github that I'm certain they will ignore: github.com/orgs/community/discussions/182241

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.