Force Succeed Required Workflow when Skipped

Hello all,

Is there a way I can force succeed a required workflow? I have a pull request that adds a ignore-paths: line to a workflow that I don’t want running when only files in a certain directory are changed. In this case, I am ignoring iOS tests when only files in the android folder are changed. But since this iOS test is required, how can I still skip it to decrease build time but also mark it as a success?

All help is greatly appreciated. Thank you!

We don’t have a way to do that natively with GitHub Actions – sorry about that!

There is a workaround but it involves some manual computation.

In this computation, determine if the relevant paths were changed, if not, you can return exit 0 to communicate that it was a successful run.

If the relevant path did change, then they would need to process it accordingly and return the intended exit code so that it “bubbles up” in the form of a check run status.

This is a rough guide on how the computation would look like:

  • Configure the workflow to trigger for a pull_request event
  • In one of the job steps, fetch the pull request’s files from the API using the GITHUB_TOKEN (https://developer.github.com/v3/pulls/#list-pull-requests-files)
  • The result is an array, each element an object with a filename field. Map the results for just the filename .
  • In the newly filtered results, check to see if any of the files contain any of the relevant paths. If at least one matches, then do whatever tests you need to do in the next steps. If none match, then this is where you can communicate “done” with an exit 0 since no further processing needs to happen.