Using the path-filtering orb blocks pull requests being merged on protected branch

Introduction:

Github has a feature in their branch protections that allows for selected status checks to be required for a pull request to be merged into a branch.

When a workflow is not run within CircleCI, there is no status check provided to Github. There is no skipped status that CircleCI sends when a workflow is not run due to a dynamic config using the path-filtering orb in CircleCI. This can result in the pull request being unable to merge as the required checks aren't satisfied.

Solution:

CircleCI provides status checks for workflows and individual jobs. Github is looking for a status check from CircleCI with the same name as the required check.

Selecting the final job(s) in workflows to be required for status checks, instead of selecting the full workflow, allows for a stand-in job with the same name to be used to satisfy the check. A stand-in workflow with a stand-in job, that has the same name as the final job in the original workflow, will run.

Instructions:

The CircleCI config uses the path filtering orb to set parameters to true if a change is made to any file within one of the directories present. There is one parameter per directory.

A script can be run after the parameters are set to check for any existing parameters. If any of the parameters were not set to true (and therefore the workflow would not run) then a stand-in parameter is set to true to trigger the stand-in workflow(s) instead.

You can find our example configuration files for the above workaround in this repository.

Additional Resources:

Path-filtering orb

Example for the stand-in workflow configuration

If the above example is not suitable for your use case, you can find an example for a slightly different approach in this repository.

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Article is closed for comments.