如何通过gh或REST API设置仅关注仓库的发布更新
仅关注GitHub仓库Release更新的实现方案
目前gh watch命令确实没有原生的release only参数来直接实现仅关注仓库Release的需求,不过可以通过以下两种方式解决:
1. 网页端配置+CLI确认
- 打开目标仓库的GitHub页面,点击顶部的「Watch」下拉按钮,选择「Custom」选项;
- 在弹出的窗口中,只勾选「Releases」,取消其他选项后保存;
- 可通过CLI命令确认当前关注状态:
gh repo view <repo_url> --json watchers,subscription
2. 用gh api直接修改订阅配置
通过GitHub REST API的仓库订阅接口,手动构造请求实现仅关注Release:
- 先提取仓库的owner和名称(例如
https://github.com/octocat/hello-world的owner是octocat,仓库名是hello-world); - 执行以下命令完成配置:
gh api --method PUT repos/{owner}/{name}/subscription \ -f subscribed=true \ -f ignored=false \ -f subscribed_events[]=release - 验证配置是否生效:
返回结果里的gh api repos/{owner}/{name}/subscriptionsubscribed_events数组应仅包含"release"。
内容的提问来源于stack exchange,提问作者jebarpg
相关产品推荐
相关产品推荐

