如何从curl或github-cli创建webhook?
这份文件。帮助不大:https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook——代码示例
尝试过这个:
curl -u <user>:<token>
-X POST
-H "Accept: application/vnd.github.v3+json"
https://api.github.com/repos/<org>/<repo>/hooks
-d '{"name":"name"}'
留给我的问题:
- 什么是
-d '{"name":"name"}'
- 如何添加配置
错误:
{
"message": "Validation Failed",
"errors": [
{
"resource": "Hook",
"code": "custom",
"message": "Config must contain URL for webhooks"
}
],
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-repository-webhook"
}
使用curl
您可以使用以下内容创建webhook:
curl "https://api.github.com/repos/<org>/<repo>/hooks"
-H "Authorization: Token YOUR_TOKEN"
-d @- << EOF
{
"name": "web",
"active": true,
"events": [
"push"
],
"config": {
"url": "http://some_webhook.ngrok.io/webhook",
"content_type": "json"
}
}
EOF
在此文档中,name
属性的值应为web
名称 | 类型 | 在中描述 | >|
---|---|---|---|
name | 字符串 | body使用web创建webhook。默认值:web。此参数仅接受值web |