How to skip required checks in GitHub Actions
As mentioned in Speeding up Jest on GitHub Actions, I've been working on a project at work recently which is seeing us migrate from CircleCI to GitHub Actions. One of the requirements that cropped up was to skip required checks in a workflow which doesn't always need to run, but does need to be run in some cases.
Unfortunately, GitHub Actions doesn't have a built-in way to skip required checks based on a condition - if you use the inbuilt path filter, it will still as a pending check, therefore it doesn't meet the merge requirements. The fix is to add a new job to your workflow which controls downstream job runs based on a file match condition.
The setup
Say we have the following workflow, which runs tests in my internal/
directory:
In order to conditionally control downstream jobs, and mark the workflow as passed if the later jobs aren't required, we can add a new job to the workflow:
Once added, you can then enforce that the 'Go Tests' workflow runs as part of your required checks, but only if the internal/
directory has changed.