使用 GitHub Api 在回购中发布到特定分支

Publish in a repo to a specific branch with GitHub Api

我正在创建一个 iOS 工作流来在我的存储库上发布注释,它是 working quite well 但现在我想在一个分支上进行以继续测试。

我正在导出备注文本并通过下一个 url:

https://api.github.com/repos/ramiro-ruiz/ramiroruiz.com/contents/content/notes/slug.md

发送授权令牌和简单的提交消息。

所有这些都已完成 on master and to send it to a branch I tried by adding ?ref=my-branch at the end of the url (https://api.github.com/repos/ramiro-ruiz/ramiroruiz.com/contents/content/notes/slug.md?ref=my-branch),但由于它一直发布到 master,所以无法正常工作。

有人知道我做错了什么吗?

create or update content API 确实包含 branch 个参数,而不是 ref 个参数。

PUT /repos/:owner/:repo/contents/:path

branch: 分支名称。
默认值:存储库的默认分支(通常是 master 或现在 main

示例:

curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/OWNER/REPO/contents/PATH \
  -d '{"branch":"sample","message":"my commit message","committer":{"name":"Monalisa Octocat","email":"octocat@github.com"},"content":"bXkgbmV3IGZpbGUgY29udGVudHM="}'
       ^^^^^^^^^^^^^^^^^