Skip to content

InsightsDevOps

Path filters and required checks in GitHub Actions

Why a workflow skipped by a paths filter leaves a pull request stuck on a pending required check, and how to run only what changed in a monorepo while keeping branch protection and merge queues working.

Published November 14, 20265 min read

A monorepo CI pipeline that builds and tests everything on every pull request gets slower with each service added. The obvious fix is a paths filter, so the payments tests only run when payments/ changes. It works until the first pull request that touches only documentation. The workflow never starts, the required check never reports, and the pull request sits on "Expected — Waiting for status to be reported" with nobody able to merge it.

This article covers why that happens, the pattern that avoids it, and what to check for merge queues.

Why a skipped workflow blocks the merge

GitHub's behavior depends on what was skipped:

What was skippedState of the required check
Whole workflow, by paths, branches or a commit messageStays Pending and blocks merging
A single job, by an if conditionReports Success and does not block

This is described in GitHub's troubleshooting guide for required status checks, and the workflow syntax reference repeats the warning for path filters: if a workflow is skipped by path filtering, its checks stay pending.

The second row is the way out. A workflow that always starts and skips jobs internally satisfies branch protection. A workflow that decides not to start does not.

The pattern: always run, decide inside

Remove paths from the trigger. Add a first job that works out what changed, make the real jobs conditional on its output, and add one final job that branch protection requires.

pull requestchangestest (if changed)ci-ok
fig. 1 — the workflow always starts, so the required check always reports
.github/workflows/ci.yml
name: ci
on:
  pull_request:
  merge_group:
 
jobs:
  changes:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: read
    outputs:
      payments: ${{ steps.filter.outputs.payments }}
      checkout: ${{ steps.filter.outputs.checkout }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          filters: |
            payments:
              - 'payments/**'
              - 'libs/shared/**'
            checkout:
              - 'checkout/**'
              - 'libs/shared/**'
 
  test-payments:
    needs: changes
    if: needs.changes.outputs.payments == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make -C payments test
 
  test-checkout:
    needs: changes
    if: needs.changes.outputs.checkout == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make -C checkout test
 
  ci-ok:
    if: always()
    needs: [changes, test-payments, test-checkout]
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo '${{ toJSON(needs.*.result) }}'
          if echo '${{ join(needs.*.result, ' ') }}' | grep -Eq 'failure|cancelled'; then
            exit 1
          fi

dorny/paths-filter is a third-party action. Pin it to a commit SHA like any other, or replace it with a few lines of git diff --name-only against the base branch if your policy rules out external actions. The pattern does not depend on it.

Three details matter:

  • Require only ci-ok. In the branch protection rule or ruleset, mark ci-ok as the required check and none of the per-service jobs. Then adding a service never needs a settings change.
  • if: always() on the gate job. Without it, a failing or skipped dependency causes ci-ok itself to be skipped. GitHub's workflow syntax reference states that if a job fails or is skipped, every job that needs it is skipped too, unless a conditional lets it continue. A skipped gate would report success exactly when something failed.
  • Fail on failure and cancelled, accept skipped. Skipped is the expected result for services that did not change. Checking for a specific bad result is safer than checking that everything was success.

Shared code and the dependency graph

A path filter is a guess about what depends on what. The filter above lists libs/shared/** under both services because a change there can break either. Miss one such directory and a pull request merges untested.

Keep the guess honest:

  • List shared directories explicitly in every filter that consumes them, and put the filter file in code review like any other config.
  • Include the workflow and build config. A change to ci.yml, a lockfile or a base image should usually run everything.
  • Prefer the build tool's graph when you have one. Nx, Turborepo, Bazel and Gradle can compute affected targets from real dependencies, which removes the hand-written lists. The gate job stays the same; only the changes job differs.
  • Run everything on a schedule. A nightly full run on the default branch catches a dependency the filter missed before it becomes a mystery.

Merge queues

If you use GitHub's merge queue, the workflow needs the merge_group trigger, as in the example above. GitHub's merge queue documentation says the merge_group event is separate from pull_request and push, and that without it status checks are not triggered when a pull request enters the queue. A required check that never reports makes every queued pull request fail.

The documentation does not say how path filters behave for merge_group events. The pattern here avoids relying on it: the workflow has no paths filter, and the changes job decides. Check that the job compares against the right base in a queue run, since a merge-group commit is not a pull request. A fallback of "if the base cannot be determined, run everything" costs minutes and prevents a hole.

Limits of the trigger-level filter

If you do use paths on a workflow, for something nobody requires such as a docs preview, know two behaviors from the workflow syntax reference:

  • Path filters are not evaluated for tag pushes.
  • If a diff contains more than 3,000 files, the workflow may not run, and if diff generation times out it always runs. Very large pull requests, such as a repository-wide rename, can behave unexpectedly.

You also cannot combine paths and paths-ignore for the same event. Use paths with ! negative patterns instead; order matters, since a later pattern can exclude or re-include earlier matches.

Rolling it out

  1. List which checks are currently required and which workflows use paths. Any required check from a path-filtered workflow is a latent stuck pull request.
  2. Move the filtering inside the workflow with a changes job.
  3. Add the ci-ok gate with always() and test it with a failing test, a docs-only change and a cancelled run.
  4. Switch the required check to ci-ok, then remove the old per-job requirements.
  5. Add merge_group if you use a queue, and run a pull request through it.
  6. Schedule a full run on the default branch.

The result is a pipeline that spends time only on what changed, a single stable name for branch protection, and no pull requests waiting for a check that was never going to run.