如何從 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"}'
讓我有疑問:
- 什么是
-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"
}
uj5u.com熱心網友回復:
使用卷曲
您可以使用以下內容來創建 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
| 姓名 | 型別 | 在 | 描述 |
|---|---|---|---|
| 姓名 | 細繩 | 身體 | 使用 web 創建一個 webhook。默認值:網路。該引數只接受值 web。 |
此處列出了可能的 Webhook 事件
使用 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://www.uj5u.com/ruanti/321175.html
標籤:github 卷曲 github-api github-cli
