프로젝트 개발 중 Slack에 있는 Github 앱을 이용하여 관련 알림을 받고 있었으나, 받을 수 있는 이벤트가 한정적이기 때문에 Github Webhook과 AWS Lambda, Slack API를 활용하여 원하는 알림을 받고자 한다.
Github에서 발생하는 이벤트는 종류가 굉장히 많다. 먼저 타입 별로 정리해보겠다.
아래 각 이벤트 아래의 더보기를 통해 어떤 이벤트인지 정리했다.
CommitCommentEvent
Commit comment 생성 이벤트.
payload 객체의 action 속성에서 'created'로 activity가 정의된다.
Key | Type | Description |
action | string | The action performed. Can be 'created'. |
comment | object | The commit comment resource. |
CreateEvent
Git branch나 tag 생성 이벤트.
("Git database" REST API 참고)
Key | Type | Description |
ref | string | The git ref resource. (위 git ref 링크에 따르면, branch의 경우 'heads/<브랜치 이름>' tag의 경우 'tags/<태그 이름>' 의 형태로 저장된다.) |
ref_type | string | The type of Git ref object created in the repository. Can be either 'branch' or 'tag'. |
master_branch | string | The name of the repository's default branch (usually 'main'). |
description | string | The repository's current description |
DeleteEvent
Git branch나 tag 삭제 이벤트. 위와 비슷하게 Git database를 참고하도록 되어 있다.
Key | Type | Description |
ref | string | The git ref resource. |
ref_type | string | 저장소에서 삭제된 git ref 객체. 'branch'나 'tag'로 표현됨. |
ForkEvent
한 유저의 'fork' 이벤트. ("forks" REST API 참고)
Key | Type | Description |
forkee | object | The created repository resource. |
GollumEvent
wiki page 생성 혹은 업데이트 이벤트. ("About wikis" 참고)
Key | Type | Description |
pages | array | The pages that were updated |
pages[][page_name] | string | The name of the page. |
pages[][title] | string | The current page title. |
pages[][action] | string | The action that was performed on the page. Can be 'created' or 'edited'. |
pages[][sha] | string | The latest commit SHA of the page. |
pages[][html_url] | string | Points to the HTML wiki page. |
IssueCommentEvent
issus나 pullrequest comment에 관련된 모든 이벤트. payload 객체의 'action' 속성에서 activity가 정의된다.
("issue comments" REST API 참고)
Key | Type | Description |
action | string | comment에 생긴 action. 'created', 'edited', 'deleted' |
changes | object | action이 'edited'일 때 comment의 변화. |
changes[body] [from] | string | action이 'edited'일 때 comment의 이전 내용. |
issue | object | comment가 속해 있는 issue. |
comment | object | comment 그 자체. |
IssuesEvent
issue에 관련된 이벤트. payload 객체의 'action' 속성에서 activity가 정의된다. ("issues" REST API 참고)
Key | Type | Description |
action | string | 'opened', 'edited', 'closed', 'reopened', 'assigned', 'unassigned', 'labeled', 'unlabeled' |
issue | object | issue 그 자체 |
changes | object | action이 'edited'일 때 issue의 변화. |
changes [title] [from] | string | action이 'edited'일 때 issue의 이전 제목. |
changes[body] [from] | string | action이 'edited'일 때 issue의 이전 내용. |
assignee | object | issue에서 assigned 되거나 unassigned 되지 않은 user |
comment | object | 이슈에서 추가되거나 삭제된 label |
MemberEvent
저장소의 collaborator에 관한 이벤트. ("collaborators" REST API 참고)
Key | Type | Description |
action | string | 사용자가 저장소에 대한 초대를 수락했음을 나타낼 때 'added' |
member | object | 추가된 user |
changes | object | action이 edited일 때 collaborator 권한에 대한 변경사항. |
changes[old_permission][from] | string | action이 edited일 때 collaborator의 이전 권한 사항. |
PublicEvent
private repository가 public으로 바뀌는 경우(공개로 전환되는 경우).
빈 payload object return.
PullRequestEvent
pull request 관련 이벤트. ("pull requests" REST API 참고)
Key | Type | Description |
action | string | 'opened', 'edited', 'closed', 'reopened', 'assigned', 'unassigned', 'review_requested', 'review_quest_removed', 'labeled', 'unlabeled', 'synchronize'. |
number | integer | pull request 번호. |
changes | object | action이 'edited'일 때의 변화. |
changes [title] [from] | string | action이 'edited'일 때의 이전 제목. |
changes[body] [from] | string | action이 'edited'일 때의 이전 내용. |
pull_request | object | pull_request 그 자체. |
PullRequestReviewEvent
pull request review에 관한 이벤트. ("pull request reviews" REST API 참고)
Key | Type | Description |
action | string | 'created' |
pull_request | object | review와 관련된 pull request |
review | object | 영향을 받은 review |
PullRequestReviewCommentEvent
pull request의 unified diff에서 review comment에 관한 이벤트. ("pull request review comments" REST API 참고)
Key | Type | Description |
action | string | 'created' |
changes | object | action이 'edited'일 때의 변화. |
changes[body] [from] | string | action이 'edited'일 때의 이전 내용. |
pull_request | object | comment가 속해 있는 pull_request |
comment | obeject | comment 그 자체. |
PullRequestReviewThreadEvent
pull request의 comment thread가 해결되거나 해결되지 않았다고 mark되는 것에 대한 이벤트.
Key | Type | Description |
action | string | - resolved: resolved로 mark됨. - unresolved: 이전의 resolved comment가 unresolved로 mark됨. |
pull_request | object | thread와 관련된 pull request. |
thread | object | 영향을 받은 thread |
PushEvent
하나 이상의 commit들이 repository branch나 tag로 push될 때의 이벤트.
Key | Type | Description |
push_id | integer | Unique identifier for the push. (push에 대한 식별자) |
size | integer | The number of commits in the push. (push에 해당하는 commit의 수) |
distinct_size | integer | The number of distinct commits in the push. (push에 해당하는 고유한 commit의 수) |
ref | string | The full git ref that was pushed. Example: 'refs/heads/main'. |
head | string | The SHA of the most recent commit on ref after the push. |
before | string | The SHA of the most recent commit on ref before the push. |
commits | array | An array of commit objects describing the pushed commits. (The array includes a maximum of 20 commits. If necessary, you can use the Commits API to fetch additional commits. This limit is applied to timeline events only and isn't applied to webhook deliveries.) |
commits[][sha] | string | The SHA of the commit. |
commits[][message] | string | The commit message. |
commits[][author] | object | The git author of the commit. |
commits[][author][name] | string | The git author's name. |
commits[][author][email] | string | The git author's email address. |
commits[][url] | url | URL that points to the commit API resource. |
commits[][distinct] | boolean | Whether this commit is distinct from any that have been pushed before. |
ReleaseEvent
release에 관련된 이벤트. ("releases" REST API 참고)
Key | Type | Description |
action | string | The action that was performed. Can be 'published'. |
changes[body][from] | string | The previous version of the body if the action was 'edited'. |
changes[name][from] | string | The previous version of the name if the action was 'edited'. |
release | object | The release object. |
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".
Key | Type | Description |
action | string | The action that was performed. This can be created. |
effective_date | string | The pending_cancellation and pending_tier_change event types will include the date the cancellation or tier change will take effect. |
changes[tier][from] | object | The tier_changed and pending_tier_change will include the original tier before the change or pending change. For more information, see the pending tier change payload. |
changes[privacy_level][from] | string | The edited event types include the details about the change when someone edits a sponsorship to change the privacy. |
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.
Key | Type | Description |
action | string | The action that was performed. Currently, can only be 'started'. |
우리 프로젝트에서는 CommitComment, Create, Delete, IssueComment, Issues, Member, Public, PullRequest, PullRequestReview, PullRequestReviewComment, PullRequestThread, Push, Release가 우선적으로 필요할 것 같다.
이제 AWS Lambda에 넣을 payload를 정리하러 가겠다.
references
https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#releaseevent
GitHub event types - GitHub Docs
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 s
docs.github.com