branch filter pattern based on repository_owner

Hi GitHub Team,

I would like to trigger GitHub Actions for:

  • only specific integration branches on main repository and maintainer’s repository, let’s say master , develop , and testing
  • all branches except those whose name ends with -wip for all forks

Is it possible? I’ve something similar to tried this:

filter:
  true: [master, develop, testing]
  false: [' **', '!** -wip']

on:
  pull_request:
  push:
    branches: ${{ filter.${{ github.repository_owner == 'my-main' || github.repository_owner == 'maintainer-id' }} }}
    tags:
      - '**'
      - '! **wip**'

Hi @sgn , 

The syntax you provided is not supported . And the idea of getting repository_owner is not working. 

There is a GITHUB_REPOSITORY in workflow default environment variables, it always shows the main repository not the forked repo. 

When a pull_request from a forked repo changed, there will be an event happened in the upstream repo (main repo) which could trigger a workflow in main repository.  

It is not that forks themselves can run arbitrary workflows,  it is that PRs raised from forks into the upstream will get run . 

There is a previous ticket with similar question: https://github.community/t5/GitHub-Actions/Why-can-t-a-self-hosted-runner-verify-repo-owner-before-running/td-p/39261

1 Like

Thanks,

We decided to have a workaround and check on

jobs.<id>.if

instead.