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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-04-17 11:00:00 +0000
Seen: 11 times
Last updated: Nov 28 '22