我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

GitHub event types

For the GitHub Events API, learn about each event type, the triggering action on GitHub, and each event's unique properties.

企业帐户可用于 GitHub Enterprise Cloud 和 GitHub Enterprise Server。 更多信息请参阅“关于企业帐户”。

本文内容

Did this doc help you?

The Events API can return different types of events triggered by activity on GitHub. Each event response contains shared properties, but has a unique payload object determined by its event type. The Event object common properties describes the properties shared by all events, and each event type describes the payload properties that are unique to the specific event.

Event object common properties

The event objects returned from the Events API endpoints have the same structure.

Event API attribute name描述
idUnique identifier for the event.
typeThe type of event. Events uses PascalCase for the name.
actorThe user that triggered the event.
actor.idThe unique identifier for the actor.
actor.loginThe username of the actor.
actor.display_loginThe specific display format of the username.
actor.gravatar_idThe unique indentifier of the Gravatar profile for the actor.
actor.urlThe REST API URL used to retrieve the user object, which includes additional user information.
actor.avatar_urlThe URL of the actor's profile image.
repoThe repository object where the event occurred.
repo.idThe unique identifier of the repository.
repo.nameThe name of the repository, which includes the owner and repository name. For example, octocat/hello-world is the name of the hello-world repository owned by the octocat user account.
repo.urlThe REST API URL used to retrive the repository object, which includes additional repository information.
payloadThe event payload object is unique to the event type. See the event type below for the event API payload object.

Example WatchEvent event object

This example shows the format of the WatchEvent response when using the Events API.

Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
      <https://api.github.com/resource?page=5>; rel="last"
[
  {
    "type": "WatchEvent",
    "public": true,
    "payload": {
    },
    "repo": {
      "id": 3,
      "name": "octocat/Hello-World",
      "url": "https://api.github.com/repos/octocat/Hello-World"
    },
    "actor": {
      "id": 1,
      "login": "octocat",
      "gravatar_id": "",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "url": "https://api.github.com/users/octocat"
    },
    "org": {
      "id": 1,
      "login": "github",
      "gravatar_id": "",
      "url": "https://api.github.com/orgs/github",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif"
    },
    "created_at": "2011-09-06T17:26:27Z",
    "id": "12345"
  }
]

CommitCommentEvent

A commit comment is created. The type of activity is specified in the action property of the payload object. For more information, see the "commit comment" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串执行的操作。 可以是 created
注释,评论对象The commit comment resource.

CreateEvent

A Git branch or tag is created. For more information, see the "Git data" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
ref字符串The git ref resource.
ref_type字符串The type of Git ref object created in the repository. Can be either branch or tag.
master_branch字符串The name of the repository's default branch (usually master).
说明字符串The repository's current description.

DeleteEvent

A Git branch or tag is deleted. For more information, see the "Git data" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
ref字符串The git ref resource.
ref_type字符串The type of Git ref oject deleted in the repository. Can be branch or tag.

ForkEvent

A user forks a repository. For more information, see the "forks" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
forkee对象The created repository resource.

GollumEvent

A wiki page is created or updated. For more information, see the "About wikis".

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
页面数组The pages that were updated.
pages[][page_name]字符串The name of the page.
pages[][title]字符串The current page title.
pages[][action]字符串The action that was performed on the page. Can be created or edited.
pages[][sha]字符串The latest commit SHA of the page.
pages[][html_url]字符串Points to the HTML wiki page.

IssueCommentEvent

Activity related to an issue comment. The type of activity is specified in the action property of the payload object. For more information, see the "issue comments" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串The action that was performed on the comment. Can be one of created, edited, or deleted.
changesobjectThe changes to the comment if the action was edited. changes[body][from]

IssuesEvent

Activity related to an issue. The type of activity is specified in the action property of the payload object. For more information, see the "issues" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串执行的操作内容. Can be one of opened, closed, reopened, assigned, unassigned, labeled, or unlabeled.
issueobjectThe issue itself. changes

MemberEvent

Activity related to repository collaborators. The type of activity is specified in the action property of the payload object. For more information, see the "collaborators" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串执行的操作内容. Can be added to indicate a user accepted an invitation to a repository.
memberobjectThe user that was added. changes

PublicEvent

When a private repository is made public. Without a doubt: the best GitHub event.

Event payload object

This event returns an empty payload object.

PullRequestEvent

Activity related to pull requests. The type of activity is specified in the action property of the payload object. For more information, see the "pull requests" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串执行的操作内容. Can be one of opened, closed, reopened, assigned, unassigned, review_requested, review_request_removed, labeled, unlabeled, and synchronize.
numberintegerThe pull request number. changes

PullRequestReviewCommentEvent

Activity related to pull request review comments in the pull request's unified diff. The type of activity is specified in the action property of the payload object. For more information, see the "pull request review comments" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串The action that was performed on the comment. 可以是 created
changesobjectThe changes to the comment if the action was edited. changes[body][from]

PushEvent

One or more commits are pushed to a repository branch or tag.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

类型描述
push_id整数Unique identifier for the push.
size整数The number of commits in the push.
distinct_size整数The number of distinct commits in the push.
ref字符串被推送的完整 git ref。 例如:refs/heads/master
头部字符串推送之后在 ref 上最近提交的 SHA。
before字符串推送之前在 ref 上最近提交的 SHA。
commits数组描述所推送提交的提交对象数组。 (该数组最多包含 20 个提交。 如有必要,可使用 Commits API 获取更多提交。 此限制仅适用于时间表事件,而不适用于 web 挂钩递送。)
commits[][sha]字符串提交的 SHA。
commits[][message]字符串提交消息.
commits[][author]对象提交的 Git 作者。
commits[][author][name]字符串Git 作者的名称。
commits[][author][email]字符串Git 作者的电子邮件地址。
commits[][url]url指向提交 API 资源的 URL。
commits[][distinct]布尔值此提交是否与之前推送的任何提交不同。

ReleaseEvent

Activity related to a release. The type of activity is specified in the action property of the payload object. For more information, see the "releases" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串执行的操作内容. Can be published.
changes[body][from]stringThe previous version of the body if the action was edited. changes[name][from]

SponsorshipEvent

Activity related to a sponsorship listing. The type of activity is specified in the action property of the payload object. For more information, see "About GitHub Sponsors".

Event payload object

类型描述
action字符串执行的操作内容. This can be created.
effective_datestringThe pending_cancellation and pending_tier_change event types will include the date the cancellation or tier change will take effect. changes[tier][from]

WatchEvent

When someone stars a repository. The type of activity is specified in the action property of the payload object. For more information, see the "starring" REST API.

The event object includes properties that are common for all events. Each event object includes a payload property and the value is unique to each event type. The payload object for this event is described below.

Event payload object

类型描述
action字符串执行的操作内容. Currently, can only be started.

Did this doc help you?