Skip to main content

События и полезные данные веб-перехватчика

Узнайте, когда происходит каждое событие веб-перехватчика и что содержит полезные данные.

Сведения о событиях и полезных данных веб-перехватчика

Вы можете создавать веб-перехватчики, которые подписываются на события, указанные на этой странице. Чтобы ограничить количество HTTP-запросов на сервер, следует подписаться только на определенные события, которые вы планируете обрабатывать. Дополнительные сведения см. в разделе Создание веб-перехватчиков.

Каждое событие веб-перехватчика на этой странице содержит описание свойств веб-перехватчика для этого события. Если событие имеет несколько действий, будут включены свойства, соответствующие каждому действию.

Каждое событие доступно только для определенных типов веб-перехватчиков. Например, веб-перехватчик организации может подписаться на team событие, но веб-перехватчик репозитория не может. Описание каждого события веб-перехватчика содержит сведения о доступности этого события. Дополнительные сведения см. в разделе Типы веб-перехватчиков.

Свойство sender

Большинство полезных данных веб-перехватчика включают sender свойство, определяющее пользователя, активировавшего событие. Иногда GitHub не удается разрешить определенного пользователя, например, когда событие происходит из внутреннего процесса, а не человека, или когда действие активации не имеет связанного пользователя. Для некоторых событий, таких как check_run и check_suite, это включает действия без принудительной отправки или проверки подлинности субъекта API Git.

В таких случаях sender пользователь заполняется ghostучетной записью заполнителя, чья login``ghost``id учетная запись не связана с реальным текущим пользователем. Не предполагайте sender всегда идентифицирует пользователя, вызвавшего событие, и учетную запись ghost пользователя в любой безопасности или бизнес-логике, которая зависит от него.

Крышка полезных данных

Полезные данные ограничены размером 25 МБ. Если событие создает большую полезные данные, GitHub не будет доставлять полезные данные для этого события веб-перехватчика. Это может произойти, например, при событии create в случае одновременной принудительной отправки большого количества ветвей или тегов. Рекомендуем отслеживать размер полезных данных, чтобы обеспечить доставку.

Заголовки доставки

Полезные данные HTTP POST, которые доставляются на настроенную конечную точку URL-адреса вашего веб-перехватчика, будут содержать несколько специальных заголовков:

  • X-GitHub-Hook-ID: Уникальный идентификатор вебхука.
  • X-GitHub-Event: Название события, которое вызвало доставку.
  • X-GitHub-Delivery: глобальный уникальный идентификатор (GUID) для идентификации события.
  • X-Hub-Signature: этот заголовок отправляется, если веб-перехватчик настроен с помощью secret. Это хэш-хэш HMAC текста запроса и создается с помощью хэш-функции SHA-1 и secret HMAC key. X-Hub-Signature предоставляется для обеспечения совместимости с существующими интеграциями. Вместо этого рекомендуется использовать более безопасный X-Hub-Signature-256 вариант.
  • X-Hub-Signature-256: этот заголовок отправляется, если веб-перехватчик настроен с помощью secret. Это шестнадцатеричный дайджест HMAC текста запроса, который генерируется с использованием хэш-функции SHA-256 и secret в качестве HMAC key. Дополнительные сведения см. в разделе Проверка доставки веб-перехватчика.
  • User-Agent: Этот заголовок всегда будет иметь префикс GitHub-Hookshot/.
  • X-GitHub-Hook-Installation-Target-Type: тип ресурса, на котором был создан вебхук.
  • X-GitHub-Hook-Installation-Target-ID: Уникальный идентификатор ресурса, по которому был создан вебхук.

Чтобы узнать, как выглядит каждый заголовок в полезных данных веб-перехватчика, см. пример доставки веб-перехватчика.

Пример доставки веб-перехватчика

Полезные данные, доставленные в формате JSON () или в формате URL-адреса (application/json``x-www-form-urlencoded). Ниже приведен пример запроса POST веб-перехватчика, использующего формат JSON.

> POST /payload HTTP/1.1

> X-GitHub-Delivery: 72d3162e-cc78-11e3-81ab-4c9367dc0958
> X-Hub-Signature: sha1=7d38cdd689735b008b3c702edd92eea23791c5f6
> X-Hub-Signature-256: sha256=d57c68ca6f92289e6987922ff26938930f6e66a2d161ef06abdf1859230aa23c
> User-Agent: GitHub-Hookshot/044aadd
> Content-Type: application/json
> Content-Length: 6615
> X-GitHub-Event: issues
> X-GitHub-Hook-ID: 292430182
> X-GitHub-Hook-Installation-Target-ID: 79929171
> X-GitHub-Hook-Installation-Target-Type: repository

> {
>   "action": "opened",
>   "issue": {
>     "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
>     "number": 1347,
>     ...
>   },
>   "repository" : {
>     "id": 1296269,
>     "full_name": "octocat/Hello-World",
>     "owner": {
>       "login": "octocat",
>       "id": 1,
>       ...
>     },
>     ...
>   },
>   "sender": {
>     "login": "octocat",
>     "id": 1,
>     ...
>   }
> }

branch_protection_configuration

This event occurs when there is a change to branch protection configurations for a repository. For more information, see "About protected branches." For information about using the APIs to manage branch protection rules, see "Branch protection rule" in the GraphQL documentation or "Branch protection" in the REST API documentation.

To subscribe to this event, a GitHub App must have at least read-level access for the "Administration" repository permission.

Доступность для branch_protection_configuration

  • Репозитории
  • Организации
  • приложения GitHub

Объект полезных данных webhook для branch_protection_configuration

All branch protections were disabled for a repository.

Параметры текста запроса веб-перехватчика
Имя., Тип, Description
action string Обязательное поле

значение: disabled

enterprise object

An enterprise on GitHub. Webhook payloads contain the enterprise property when the webhook is configured on an enterprise account or an organization that's part of an enterprise account. For more information, see "About enterprise accounts."

installation object

The GitHub App installation. Webhook payloads contain the installation property when the event is configured for and sent to a GitHub App. For more information, see "Using webhooks with GitHub Apps."

organization object

A GitHub organization. Webhook payloads contain the organization property when the webhook is configured for an organization, or when the event occurs from activity in a repository owned by an organization.

repository object Обязательное поле

The repository on GitHub where the event occurred. Webhook payloads contain the repository property when the event occurs from activity in a repository.

sender object Обязательное поле

A GitHub user.

branch_protection_rule

This event occurs when there is activity relating to branch protection rules. For more information, see "About protected branches." For information about the APIs to manage branch protection rules, see the GraphQL documentation or "Branch protection" in the REST API documentation.

To subscribe to this event, a GitHub App must have at least read-level access for the "Administration" repository permission.

Доступность для branch_protection_rule

  • Репозитории
  • Организации
  • приложения GitHub

Объект полезных данных webhook для branch_protection_rule

A branch protection rule was created.

Параметры текста запроса веб-перехватчика
Имя., Тип, Description
action string Обязательное поле

значение: created

enterprise object

An enterprise on GitHub. Webhook payloads contain the enterprise property when the webhook is configured on an enterprise account or an organization that's part of an enterprise account. For more information, see "About enterprise accounts."

installation object

The GitHub App installation. Webhook payloads contain the installation property when the event is configured for and sent to a GitHub App. For more information, see "Using webhooks with GitHub Apps."

organization object

A GitHub organization. Webhook payloads contain the organization property when the webhook is configured for an organization, or when the event occurs from activity in a repository owned by an organization.

repository object Обязательное поле

The repository on GitHub where the event occurred. Webhook payloads contain the repository property when the event occurs from activity in a repository.

rule object Обязательное поле

The branch protection rule. Includes a name and all the branch protection settings applied to branches that match the name. Binary settings are boolean. Multi-level configurations are one of off, non_admins, or everyone. Actor and build lists are arrays of strings.

sender object Обязательное поле

A GitHub user.

check_run

This event occurs when there is activity relating to a check run. For information about check runs, see "Getting started with the Checks API." For information about the APIs to manage check runs, see the GraphQL API documentation or "Check Runs" in the REST API documentation.

For activity relating to check suites, use the check-suite event.

To subscribe to this event, a GitHub App must have at least read-level access for the "Checks" repository permission. To receive the rerequested and requested_action event types, the app must have at least write-level access for the "Checks" permission. GitHub Apps with write-level access for the "Checks" permission are automatically subscribed to this webhook event.

Repository and organization webhooks only receive payloads for the created and completed event types in repositories.

The API only looks for pushes in the repository where the check run was created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.

Доступность для check_run

  • Репозитории
  • Организации
  • приложения GitHub

Объект полезных данных webhook для check_run

A check run was completed, and a conclusion is available.

Параметры текста запроса веб-перехватчика
Имя., Тип, Description
action string

значение: completed

check_run object Обязательное поле

A check performed on the code of a given code change

installation object

The GitHub App installation. Webhook payloads contain the installation property when the event is configured for and sent to a GitHub App. For more information, see "Using webhooks with GitHub Apps."

enterprise object

An enterprise on GitHub. Webhook payloads contain the enterprise property when the webhook is configured on an enterprise account or an organization that's part of an enterprise account. For more information, see "About enterprise accounts."

organization object

A GitHub organization. Webhook payloads contain the organization property when the webhook is configured for an organization, or when the event occurs from activity in a repository owned by an organization.

repository object Обязательное поле

The repository on GitHub where the event occurred. Webhook payloads contain the repository property when the event occurs from activity in a repository.

sender object Обязательное поле

A GitHub user.

check_suite

This event occurs when there is activity relating to a check suite. For information about check suites, see "Getting started with the Checks API." For information about the APIs to manage check suites, see the GraphQL API documentation or "Check Suites" in the REST API documentation.

For activity relating to check runs, use the check_run event.

To subscribe to this event, a GitHub App must have at least read-level access for the "Checks" permission. To receive the requested and rerequested event types, the app must have at least write-level access for the "Checks" permission. GitHub Apps with write-level access for the "Checks" permission are automatically subscribed to this webhook event.

Repository and organization webhooks only receive payloads for the completed event types in repositories.

The API only looks for pushes in the repository where the check suite was created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.

Доступность для check_suite

  • Репозитории
  • Организации
  • приложения GitHub

Объект полезных данных webhook для check_suite

All check runs in a check suite have completed, and a conclusion is available.

Параметры текста запроса веб-перехватчика
Имя., Тип, Description
action string Обязательное поле