如何从curl 或github cli 创建webhook?
这个文档。没有多大帮助:https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook--code-samples https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook--code-samples
尝试过这个:
curl -u <user>:<token>\
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/<org>/<repo>/hooks \
-d '{"name":"name"}'
给我留下了疑问:
- What is
-d '{"name":"name"}'
- 如何添加配置
Errors:
{
"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"
}
使用卷曲
您可以使用以下命令来创建 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
From this doc https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook, name
财产应该有价值web
Name |
Type |
In |
Description |
name |
string |
body |
Use web to create a webhook. Default: web. This parameter only accepts the value web. |
列出了可能的 Webhook 事件here https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads
使用 Github CLI
gh api /repos/<org>/<repo>/hooks \
--input - <<< '{
"name": "web",
"active": true,
"events": [
"watch"
],
"config": {
"url": "https://some_webhook.ngrok.io/webhook",
"content_type": "json"
}
}'
查看gh api https://cli.github.com/manual/gh_api
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)