ninja is used to build cpp project, big project like chrome and v8 use it by default. So it would be helpful to bring it to macOS. It can be installed by brew too.
I find an action (Install ninja-build tool) from GitHub Marketplace, this action is used to download and install the ninja-build tool into the PATH for the job.
Of course, you also can add a self-hosted runner on your local machine (or your VM) where the ninja-build tool has been installed, so that you do not need to install the ninja-build tool every time when running workflow.