Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inputs.webhooks): Add inputs.webhooks.github workflow events support #16355

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 60 additions & 21 deletions plugins/inputs/webhooks/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The format is as follows:
The tag values and field values show the place on the incoming JSON object
where the data is sourced from.

### [`commit_comment` event](https://developer.github.com/v3/activity/events/types/#commitcommentevent)
### [`commit_comment` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#commit_comment)

**Tags:**

Expand All @@ -46,7 +46,7 @@ where the data is sourced from.
* 'commit' = `event.comment.commit_id` string
* 'comment' = `event.comment.body` string

### [`create` event](https://developer.github.com/v3/activity/events/types/#createevent)
### [`create` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#create)

**Tags:**

Expand All @@ -64,7 +64,7 @@ where the data is sourced from.
* 'ref' = `event.ref` string
* 'refType' = `event.ref_type` string

### [`delete` event](https://developer.github.com/v3/activity/events/types/#deleteevent)
### [`delete` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#delete)

**Tags:**

Expand All @@ -82,7 +82,7 @@ where the data is sourced from.
* 'ref' = `event.ref` string
* 'refType' = `event.ref_type` string

### [`deployment` event](https://developer.github.com/v3/activity/events/types/#deploymentevent)
### [`deployment` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#deployment)

**Tags:**

Expand All @@ -102,7 +102,7 @@ where the data is sourced from.
* 'environment' = `event.deployment.environment` string
* 'description' = `event.deployment.description` string

### [`deployment_status` event](https://developer.github.com/v3/activity/events/types/#deploymentstatusevent)
### [`deployment_status` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#deployment_status)

**Tags:**

Expand All @@ -124,7 +124,7 @@ where the data is sourced from.
* 'depState' = `event.deployment_status.state` string
* 'depDescription' = `event.deployment_status.description` string

### [`fork` event](https://developer.github.com/v3/activity/events/types/#forkevent)
### [`fork` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#fork)

**Tags:**

Expand All @@ -141,7 +141,7 @@ where the data is sourced from.
* 'issues' = `event.repository.open_issues_count` int
* 'forkee' = `event.forkee.repository` string

### [`gollum` event](https://developer.github.com/v3/activity/events/types/#gollumevent)
### [`gollum` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#gollum)

**Tags:**

Expand All @@ -157,7 +157,7 @@ where the data is sourced from.
* 'forks' = `event.repository.forks_count` int
* 'issues' = `event.repository.open_issues_count` int

### [`issue_comment` event](https://developer.github.com/v3/activity/events/types/#issuecommentevent)
### [`issue_comment` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#issue_comment)

**Tags:**

Expand All @@ -177,7 +177,7 @@ where the data is sourced from.
* 'comments' = `event.issue.comments` int
* 'body' = `event.comment.body` string

### [`issues` event](https://developer.github.com/v3/activity/events/types/#issuesevent)
### [`issues` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#issues)

**Tags:**

Expand All @@ -197,7 +197,7 @@ where the data is sourced from.
* 'title' = `event.issue.title` string
* 'comments' = `event.issue.comments` int

### [`member` event](https://developer.github.com/v3/activity/events/types/#memberevent)
### [`member` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#member)

**Tags:**

Expand All @@ -215,7 +215,7 @@ where the data is sourced from.
* 'newMember' = `event.sender.login` string
* 'newMemberStatus' = `event.sender.site_admin` bool

### [`membership` event](https://developer.github.com/v3/activity/events/types/#membershipevent)
### [`membership` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#membership)

**Tags:**

Expand All @@ -229,7 +229,7 @@ where the data is sourced from.
* 'newMember' = `event.sender.login` string
* 'newMemberStatus' = `event.sender.site_admin` bool

### [`page_build` event](https://developer.github.com/v3/activity/events/types/#pagebuildevent)
### [`page_build` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#page_build)

**Tags:**

Expand All @@ -245,7 +245,7 @@ where the data is sourced from.
* 'forks' = `event.repository.forks_count` int
* 'issues' = `event.repository.open_issues_count` int

### [`public` event](https://developer.github.com/v3/activity/events/types/#publicevent)
### [`public` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#public)

**Tags:**

Expand All @@ -261,7 +261,7 @@ where the data is sourced from.
* 'forks' = `event.repository.forks_count` int
* 'issues' = `event.repository.open_issues_count` int

### [`pull_request_review_comment` event](https://developer.github.com/v3/activity/events/types/#pullrequestreviewcommentevent)
### [`pull_request_review_comment` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request_review_comment)

**Tags:**

Expand All @@ -288,7 +288,7 @@ where the data is sourced from.
* 'commentFile' = `event.comment.file` string
* 'comment' = `event.comment.body` string

### [`pull_request` event](https://developer.github.com/v3/activity/events/types/#pullrequestevent)
### [`pull_request` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request)

**Tags:**

Expand All @@ -313,7 +313,7 @@ where the data is sourced from.
* 'deletions' = `event.pull_request.deletions` int
* 'changedFiles' = `event.pull_request.changed_files` int

### [`push` event](https://developer.github.com/v3/activity/events/types/#pushevent)
### [`push` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#push)

**Tags:**

Expand All @@ -332,7 +332,7 @@ where the data is sourced from.
* 'before' = `event.before` string
* 'after' = `event.after` string

### [`repository` event](https://developer.github.com/v3/activity/events/types/#repositoryevent)
### [`repository` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#repository)

**Tags:**

Expand All @@ -348,7 +348,7 @@ where the data is sourced from.
* 'forks' = `event.repository.forks_count` int
* 'issues' = `event.repository.open_issues_count` int

### [`release` event](https://developer.github.com/v3/activity/events/types/#releaseevent)
### [`release` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#release)

**Tags:**

Expand All @@ -365,7 +365,7 @@ where the data is sourced from.
* 'issues' = `event.repository.open_issues_count` int
* 'tagName' = `event.release.tag_name` string

### [`status` event](https://developer.github.com/v3/activity/events/types/#statusevent)
### [`status` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#status)

**Tags:**

Expand All @@ -383,7 +383,7 @@ where the data is sourced from.
* 'commit' = `event.sha` string
* 'state' = `event.state` string

### [`team_add` event](https://developer.github.com/v3/activity/events/types/#teamaddevent)
### [`team_add` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#team_add)

**Tags:**

Expand All @@ -400,7 +400,7 @@ where the data is sourced from.
* 'issues' = `event.repository.open_issues_count` int
* 'teamName' = `event.team.name` string

### [`watch` event](https://developer.github.com/v3/activity/events/types/#watchevent)
### [`watch` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#watch)

**Tags:**

Expand All @@ -415,3 +415,42 @@ where the data is sourced from.
* 'stars' = `event.repository.stargazers_count` int
* 'forks' = `event.repository.forks_count` int
* 'issues' = `event.repository.open_issues_count` int

### [`workflow_job` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_job)

**Tags:**

* 'event' = `headers[X-Github-Event]` string
* 'action' = `event.action` string
* 'repository' = `event.repository.full_name` string
* 'private' = `event.repository.private` bool
* 'user' = `event.sender.login` string
* 'admin' = `event.sender.site_admin` bool
* 'name' = `event.workflow_job.name` string
* 'conclusion' = `event.workflow_job.conclusion` string

**Fields:**

* 'run_attempt' = `event.workflow_job.run_attempt` int
* 'queue_time' = `event.workflow_job.started_at - event.workflow_job.created_at at event.action = in_progress in milliseconds` int
* 'run_time' = `event.workflow_job.completed_at - event.workflow_job.started_at at event.action = completed in milliseconds` int
* 'head_branch' = `event.workflow_job.head_branch` string

### [`workflow_run` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_run)

**Tags:**

* 'event' = `headers[X-Github-Event]` string
* 'action' = `event.action` string
* 'repository' = `event.repository.full_name` string
* 'private' = `event.repository.private` bool
* 'user' = `event.sender.login` string
* 'admin' = `event.sender.site_admin` bool
* 'name' = `event.workflow_run.name` string
* 'conclusion' = `event.workflow_run.conclusion` string

**Fields:**

* 'run_attempt' = `event.workflow_run.run_attempt` int
* 'run_time' = `event.workflow_run.completed_at - event.workflow_run.run_started_at at event.action = completed in milliseconds` int
* 'head_branch' = `event.workflow_run.head_branch` string
4 changes: 4 additions & 0 deletions plugins/inputs/webhooks/github/github_webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ func (gh *Webhook) newEvent(data []byte, name string) (event, error) {
return generateEvent(data, &teamAddEvent{})
case "watch":
return generateEvent(data, &watchEvent{})
case "workflow_job":
return generateEvent(data, &workflowJobEvent{})
case "workflow_run":
return generateEvent(data, &workflowRunEvent{})
}
return nil, &newEventError{"Not a recognized event type"}
}
Expand Down
Loading
Loading