1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/content/developers/webhooks-and-events/webhooks/receiving-webhooks-with-the-github-cli.md
2022-11-04 10:33:14 +00:00

2.8 KiB

title, intro, versions, topics, shortTitle
title intro versions topics shortTitle
Receiving webhooks with the GitHub CLI You can use the {% data variables.product.prodname_cli %} to test webhooks in your development environment without the complexity of port forwarding or third-party tools.
feature
cli-webhook-forwarding
Webhooks
Receiving webhooks with the GitHub CLI

About receiving webhooks with {% data variables.product.prodname_cli %}

{% note %}

Note: Receiving webhooks with the {% data variables.product.prodname_cli %} is currently in limited public beta and subject to change. To sign up for the beta, reply to our GitHub Community discussion. You may not be added immediately. You will receive an email notification once you have been added to the beta.

{% endnote %}

When you make changes to your integration code, running the code in a local environment lets you test and iterate quickly without deploying the code. You can use {% data variables.product.prodname_cli %} to forward webhooks to your local environment.

{% note %}

Note: Webhook forwarding in the {% data variables.product.prodname_cli %} only works with repository and organization webhooks. If you want to test sponsorship, GitHub App, enterprise, or Marketplace webhooks locally, you'll need to do this manually. For more information, see "Creating webhooks."

{% endnote %}

Recieving webhooks with {% data variables.product.prodname_cli %}

{% data reusables.cli.cli-learn-more %}

  1. To install the {% data variables.product.prodname_cli %} extension to enable webhook forwarding, use the extension install subcommand.

    gh extension install cli/gh-webhook
    
  2. Start your application locally, and take a note of the URL where it's expecting to receive webhooks. This guide assumes that your application is listening for webhook events at http://localhost:3000/webhook.

  3. To set up webhooks to be delivered to your application, run the webhook forward subcommand. Replace REPOSITORY with the name of your repository. For example, monalisa/octocat. Replace EVENTS with a comma-separated list of the events that you want to receive. For example, issues,pull_request. Replace URL with the local URL where your application expects to receive webhooks. For example, "http://localhost:3000/webhook". To listen for organization webhooks instead of repository webhooks, replace the --repo flag with the --org flag. For example --org="octo-org".

    gh webhook forward --repo=REPOSITORY --events=EVENTS --url=URL
    

Leave the command running in the background. It will receive all of the specified events for the specified repository and forward them to your webhook handler running at the specified URL.