Skip to content

Commit bbd5d19

Browse files
author
Aurelia
authored
Add struct for workflow_job event (#2038)
1 parent 159aed6 commit bbd5d19

File tree

7 files changed

+100
-0
lines changed

7 files changed

+100
-0
lines changed

github/event.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
124124
payload = &WatchEvent{}
125125
case "WorkflowDispatchEvent":
126126
payload = &WorkflowDispatchEvent{}
127+
case "WorkflowJobEvent":
128+
payload = &WorkflowJobEvent{}
127129
case "WorkflowRunEvent":
128130
payload = &WorkflowRunEvent{}
129131
}

github/event_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,20 @@ type WorkflowDispatchEvent struct {
10831083
Sender *User `json:"sender,omitempty"`
10841084
}
10851085

1086+
// WorkflowJobEvent is triggered when a job is queued, started or completed.
1087+
//
1088+
// GitHub API docs: pending
1089+
type WorkflowJobEvent struct {
1090+
WorkflowJob *WorkflowJob `json:"workflow_job,omitempty"`
1091+
1092+
Action *string `json:"action,omitempty"`
1093+
1094+
// The following fields are only populated by Webhook events.
1095+
Org *Organization `json:"organization,omitempty"`
1096+
Repo *Repository `json:"repository,omitempty"`
1097+
Sender *User `json:"sender,omitempty"`
1098+
}
1099+
10861100
// WorkflowRunEvent is triggered when a GitHub Actions workflow run is requested or completed.
10871101
//
10881102
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#workflow_run

github/github-accessors.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/messages.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ var (
9292
"user": "UserEvent",
9393
"watch": "WatchEvent",
9494
"workflow_dispatch": "WorkflowDispatchEvent",
95+
"workflow_job": "WorkflowJobEvent",
9596
"workflow_run": "WorkflowRunEvent",
9697
}
9798
)

github/messages_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ func TestParseWebHook(t *testing.T) {
450450
payload: &WorkflowDispatchEvent{},
451451
messageType: "workflow_dispatch",
452452
},
453+
{
454+
payload: &WorkflowJobEvent{},
455+
messageType: "workflow_job",
456+
},
453457
{
454458
payload: &WorkflowRunEvent{},
455459
messageType: "workflow_run",

github/repos_hooks_deliveries_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ var hookDeliveryPayloadTypeToStruct = map[string]interface{}{
155155
"user": &UserEvent{},
156156
"watch": &WatchEvent{},
157157
"workflow_dispatch": &WorkflowDispatchEvent{},
158+
"workflow_job": &WorkflowJobEvent{},
158159
"workflow_run": &WorkflowRunEvent{},
159160
}
160161

0 commit comments

Comments
 (0)