ドキュメントには頻繁に更新が加えられ、その都度公開されています。本ページの翻訳はまだ未完成な部分があることをご了承ください。最新の情報については、英語のドキュメンテーションをご参照ください。本ページの翻訳に問題がある場合はこちらまでご連絡ください。

このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2020-11-12. 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 パフォーマンスの向上、セキュリティの改善、新機能のためには、最新バージョンのGitHub Enterpriseにアップグレードしてください。 アップグレードに関する支援については、GitHub Enterprise supportに連絡してください。

Creating webhooks

Learn to build a webhook, choosing the events your webhook will listen for on GitHub and how to set up a server to receive and manage the webhook payload.

ここには以下の内容があります:

Now that we understand the basics of webhooks, let's go through the process of building out our own webhook powered integration. In this tutorial, we'll create a repository webhook that will be responsible for listing out how popular our repository is, based on the number of Issues it receives per day.

Creating a webhook is a two-step process. You'll first need to set up how you want your webhook to behave through GitHub Enterprise Server--what events should it listen to. After that, you'll set up your server to receive and manage the payload.

You can use the repository, organization, and app webhook REST APIs to create, update, delete, and ping webhooks. For more information, see:

Setting up a Webhook

You can install webhooks on an organization or on a specific repository.

To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook.

Alternatively, you can choose to build and manage a webhook through the Webhooks API.

Webhooks require a few configuration options before you can make use of them. We'll go through each of these settings below.

Payload URL

The payload URL is the URL of the server that will receive the webhook POST requests.

Since we're developing locally for our tutorial, let's set it to http://localhost:4567/payload. We'll explain why in the Configuring Your Server docs.

Content Type

webhookは、様々なコンテンツタイプを使って配信できます。

  • application/jsonコンテンツタイプは、JSONペイロードをPOSTリクエストのボディとして直接配信します。
  • application/x-www-form-urlencodedコンテンツタイプは、JSONペイロードをpayloadと呼ばれるフォームのパラメータとして送信します。

要求に最適なものを選んでください。 For this tutorial, the default content type of application/json is fine.

Secret

Setting a webhook secret allows you to ensure that POST requests sent to the payload URL are from GitHub Enterprise Server. When you set a secret, you'll receive the X-Hub-Signature header in the webhook POST request. For more information on how to use a secret with a signature header to secure your webhook payloads, see "Securing your webhooks."

SSL Verification

If your "Payload URL" is a secure site (HTTPS), you will have the option to configure the SSL verification settings. If your "Payload URL" is not secure (HTTP), GitHub will not display this option. By default, GitHub verifies the SSL certificate of your website when delivering webhook payloads. SSL verification helps ensure that hook payloads are delivered to your URL endpoint securely. You have the option to disable SSL, but we recommend keeping Enable SSL verification selected.

Active

デフォルトでは、webhookの配信は「Active」です。 You can choose to disable the delivery of webhook payloads by deselecting "Active."

イベント

Events are at the core of webhooks. These webhooks fire whenever a certain action is taken on the repository, which your server's payload URL intercepts and acts upon.

A full list of webhook events, and when they execute, can be found in the webhooks API reference.

Since our webhook is dealing with Issues in a repository, we'll click Let me select individual events and then Issues. Make sure you select Active to receive issue events for triggered webhooks. You can also select all events using the default option.

When you're finished, click Add webhook. いかがですか。 Now that you created the webhook, it's time to set up our local server to test the webhook. Head on over to Configuring Your Server to learn how to do that.

Wildcard Event

To configure a webhook for all events, use the wildcard (*) character to specify the webhook events. When you add the wildcard event, we'll replace any existing events you have configured with the wildcard event and send you payloads for all supported events. You'll also automatically get any new events we might add in the future.