Chr*_* G. 4 curl github github-api github-cli
如何从curl 或github cli 创建webhook?
这个文档。没有多大帮助: 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"}'
Run Code Online (Sandbox Code Playgroud)
给我留下了疑问:
-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"
}
Run Code Online (Sandbox Code Playgroud)
您可以使用以下命令来创建 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
Run Code Online (Sandbox Code Playgroud)
从这个文档来看,name属性应该具有值web
| 姓名 | 类型 | 在 | 描述 |
|---|---|---|---|
| 姓名 | 细绳 | 身体 | 使用 web 创建 webhook。默认:网络。该参数仅接受值 web。 |
此处列出了可能的 Webhook 事件
gh api /repos/<org>/<repo>/hooks \
--input - <<< '{
"name": "web",
"active": true,
"events": [
"watch"
],
"config": {
"url": "https://some_webhook.ngrok.io/webhook",
"content_type": "json"
}
}'
Run Code Online (Sandbox Code Playgroud)
检查gh api
| 归档时间: |
|
| 查看次数: |
2742 次 |
| 最近记录: |