Return passing status on Github workflow when using paths-ignore

Viewed 469

I'm using a Github workflow to run tests. Because the setup can take a while, we want to skip running the tests when no code was changed. So we are using paths-ignore like this:

on:
  pull_request:
    branches:
      - develop
    paths-ignore:
      - '*.md'

The problem is that we have a protected branch here that requires a check to pass before a branch can be merged. There seems to be some workarounds https://github.community/t/feature-request-conditional-required-checks/16761/20 but they are pretty clunky. Is there an elegant and idiomatic way to return a passing status here for a job that was essentially skipped?

1 Answers

Elegant and idiomatic, evidently not. The conclusion elsewhere (GitHub community forum, Reddit) is that this is expected behavior, at least right now.

The two main workarounds people seem to be using are:

  • Run all required status checks on all PRs, even the slow ones. Sigh.
  • Use paths-filter or a homegrown alternative (example) inside the required workflows, as part of their execution, and skip the actual work and return success if no relevant files were changed.
Related