gh: Move away from using curl for patches and to GitHub API

:warning: This initially failing PR is an TODO item for `am/apply` commands. We need to switch them over to the GitHub API so that they won't have any external dependencies.

/cc @jingweno
I can do that. I'll be away all day but I can do it in the evening. Or you can try adding to this PR yourself if you feel like it.