1 | initial version |
To create a Github webhook using the Github CLI, follow these steps:
Login to Github using the CLI. You can use the following command to login:
auth login
Once you are authenticated, navigate to the repository where you want to create the webhook. You can use the following command:
repo view <username>/<repository-name>
Check if there are any existing webhooks in the repository using the following command:
api repos/<username>/<repository-name>/hooks
If there are no existing webhooks, you can create a new webhook using the following command:
api repos/<username>/<repository-name>/hooks --input - << EOF
{
"name": "web",
"active": true,
"events": [
"push"
],
"config": {
"url": "<your-webhook-url>",
"content_type": "json"
}
}
EOF
Replace <your-webhook-url>
with the URL of your webhook endpoint.
Press Enter to create the webhook. If successful, the response will include the webhook details.
That's it! You have created a Github webhook using the Github CLI.