Branches-ignore filter not working for pull-request events


At decidim/decidim we’re using GitHub Actions to run the test suite on every push in every PR, and on every push in specific branches. So far it’s working fine.

We’re using Crowdin to handle translations for our application. Crowdin requires access to our repo, and creates a PR with a specific prefix. We set this prefix to chore/l10n_, so we consider any PR coming from a branch matching this prefix to be coming from Crowdin, and thus we want to skip the test suite for those PRs. Again, our current setup so far is working fine, but it’s adding a lot of jobs to our queue that we know they won’t run and we want to totally ignore them.

Here’s our first attempt at it:

name: "CI"
      - develop
      - release/*
      - "*-stable"
      - "chore/l10n*"

But this doesn’t seem to be working, as PRs matching the branch name have the jobs enqueued (but skipped later thanks to a check on the job).

I’ve tried different approaches:

  1. Using the ** character instead of a single *:
      - "chore/l10n**"
  1. Using a negative filter on branches::
      - "!chore/l10n**"
  1. Manually specifying the branches to ignore:
      - "**"
      - "!chore/fix-ci-ignores-for-crowdin"
      - "!chore/l10n**"

None of these did what I expected to do. You can see my attempts in Fix pattern mathing when ignoring branches in CI by mrcasals · Pull Request #7570 · decidim/decidim · GitHub

I’d like to have some workflows run for all pushes in specific branches and for all PRs except for those PRs matching a specific branch name pattern.

How can I get this working?


on.pull_request.branches and on.pull_request.branches-ignore filter for the target branch (the branch you want to merge into), not the source branch, as described in the documentation.

The closest thing that comes to mind would be to add an if: condition on the job that checks github.head_ref (see github context) for pull_request events. If you have a bunch of jobs in the workflow that might get unwieldy, though.

I have re-read the documentation and it still isn’t clear that it’s the target branch that gets evaluated.