Filter pattern regex works on push but not on pull_request

Hello everyone,

This does not work…

name: Create Changelog
on:
  pull_request:
    branches:
      - '[a-zA-Z]+/[a-zA-Z]+-[0-9]+/**'
    types: [opened, edited, reopened, synchronize, ready_for_review]

But this does…

name: Create Changelog
on:
  push:
    branches:
      - '[a-zA-Z]+/[a-zA-Z]+-[0-9]+/**'

I changed pull_request to push

Can someone tell me if pull_request does not use the filter pattern or is this a bug on Github’s end?

Could you explain a bit more what you mean by “not working”? Like, what behavior are you seeing, and what would you expect instead? If possible, linking examples is best.

@airtower-luna Sorry, some context would definitely be helpful…

This action creates a changelog on the fly. We want to create the changelog based off the title of the PR. We are using the github.event.pull_request object to grab the title of the PR, create a file based off of the branch name, and push the change up if the file doesn’t already exist.

Our branches are all structured like so: feature/JIRA-123/this-is-a-feature but sometimes we have the occasional spike that skips the changelog process. We want to make sure that the branches that match the above structure are the only ones creating changelogs.

The thing is the check never shows up to fire off the changelog action. It doesn’t do anything at all, but if I change it from on: pull request to on: push using the same exact Regex, the action will fire (but fail because push does not have the PR object).

I have experimented a bit. Things like **/**/** seem to match. Things like **/DEV-*/** do not.

Let me know if you need more info.

Thanks.

The branch filter for pull request events filters for the name of the target branch, not the source branch (the one containing the commits you want to merge). Maybe that’s causing some confusion here?

on:
  pull_request:
    branches:
      - '[a-zA-Z]+/[a-zA-Z]+-[0-9]+/**'

So this workflow won’t run unless you create a PR to merge into one of your feature branches. Well, or a branch using a similar naming scheme.

1 Like