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 skipped | State of the required check |
|---|---|
Whole workflow, by paths, branches or a commit message | Stays Pending and blocks merging |
A single job, by an if condition | Reports 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.
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
fidorny/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, markci-okas 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 causesci-okitself 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
failureandcancelled, acceptskipped. Skipped is the expected result for services that did not change. Checking for a specific bad result is safer than checking that everything wassuccess.
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
changesjob 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
- 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. - Move the filtering inside the workflow with a
changesjob. - Add the
ci-okgate withalways()and test it with a failing test, a docs-only change and a cancelled run. - Switch the required check to
ci-ok, then remove the old per-job requirements. - Add
merge_groupif you use a queue, and run a pull request through it. - 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.