Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To create a Github webhook using the Github CLI, follow these steps:

  1. Open your terminal and make sure you have the latest version of the Github CLI installed.
  2. Login to Github using the CLI. You can use the following command to login:

    auth login

  3. 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>

  4. Check if there are any existing webhooks in the repository using the following command:

    api repos/<username>/<repository-name>/hooks

  5. 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

  6. Replace <your-webhook-url> with the URL of your webhook endpoint.

  7. 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.