Recently had to do this and it was a bit complicated until I found out
the amazing CMake FindPython
module, which is built-in to CMake.
Recording this here in case I need it again.
I'm also taking the time to fiddle around with GitHub Actions for the first time (I mostly used Travis-CI and GitLab-CI until now).