-
Notifications
You must be signed in to change notification settings - Fork 10
/
event.go
283 lines (254 loc) · 8.09 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// Autogenerated by go run internal/genevents/main.go. DO NOT EDIT.
package goaction
import (
"encoding/json"
"fmt"
"os"
"github.com/google/go-github/v31/github"
)
// A Github action triggering event.
// See https://help.github.com/en/actions/reference/events-that-trigger-workflows.
type EventType string
// All Github action event types.
const (
EventCheckRun EventType = "check_run"
EventCheckSuite EventType = "check_suite"
EventCreate EventType = "create"
EventDelete EventType = "delete"
EventDeployment EventType = "deployment"
EventFork EventType = "fork"
EventGollum EventType = "gollum"
EventIssueComment EventType = "issue_comment"
EventIssues EventType = "issues"
EventLabel EventType = "label"
EventMilestone EventType = "milestone"
EventPageBuild EventType = "page_build"
EventProject EventType = "project"
EventProjectCard EventType = "project_card"
EventPublic EventType = "public"
EventPullRequest EventType = "pull_request"
EventPullRequestReview EventType = "pull_request_review"
EventPullRequestReviewComment EventType = "pull_request_review_comment"
EventPush EventType = "push"
EventRegistryPackage EventType = "registry_package"
EventRelease EventType = "release"
EventStatus EventType = "status"
EventWatch EventType = "watch"
EventSchedule EventType = "schedule"
EventRepositoryDispatch EventType = "repository_dispatch"
)
// GetCheckRun returns information about a current check run.
func GetCheckRun() (*github.CheckRunEvent, error) {
if Event != EventCheckRun {
return nil, fmt.Errorf("not 'check_run' event")
}
var i github.CheckRunEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetCheckSuite returns information about a current check suite.
func GetCheckSuite() (*github.CheckSuiteEvent, error) {
if Event != EventCheckSuite {
return nil, fmt.Errorf("not 'check_suite' event")
}
var i github.CheckSuiteEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetCreate returns information about a current create.
func GetCreate() (*github.CreateEvent, error) {
if Event != EventCreate {
return nil, fmt.Errorf("not 'create' event")
}
var i github.CreateEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetDelete returns information about a current delete.
func GetDelete() (*github.DeleteEvent, error) {
if Event != EventDelete {
return nil, fmt.Errorf("not 'delete' event")
}
var i github.DeleteEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetDeployment returns information about a current deployment.
func GetDeployment() (*github.DeploymentEvent, error) {
if Event != EventDeployment {
return nil, fmt.Errorf("not 'deployment' event")
}
var i github.DeploymentEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetFork returns information about a current fork.
func GetFork() (*github.ForkEvent, error) {
if Event != EventFork {
return nil, fmt.Errorf("not 'fork' event")
}
var i github.ForkEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetGollum returns information about a current gollum.
func GetGollum() (*github.GollumEvent, error) {
if Event != EventGollum {
return nil, fmt.Errorf("not 'gollum' event")
}
var i github.GollumEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetIssueComment returns information about a current issue comment.
func GetIssueComment() (*github.IssueCommentEvent, error) {
if Event != EventIssueComment {
return nil, fmt.Errorf("not 'issue_comment' event")
}
var i github.IssueCommentEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetIssues returns information about a current issues.
func GetIssues() (*github.IssuesEvent, error) {
if Event != EventIssues {
return nil, fmt.Errorf("not 'issues' event")
}
var i github.IssuesEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetLabel returns information about a current label.
func GetLabel() (*github.LabelEvent, error) {
if Event != EventLabel {
return nil, fmt.Errorf("not 'label' event")
}
var i github.LabelEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetMilestone returns information about a current milestone.
func GetMilestone() (*github.MilestoneEvent, error) {
if Event != EventMilestone {
return nil, fmt.Errorf("not 'milestone' event")
}
var i github.MilestoneEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetPageBuild returns information about a current page build.
func GetPageBuild() (*github.PageBuildEvent, error) {
if Event != EventPageBuild {
return nil, fmt.Errorf("not 'page_build' event")
}
var i github.PageBuildEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetProject returns information about a current project.
func GetProject() (*github.ProjectEvent, error) {
if Event != EventProject {
return nil, fmt.Errorf("not 'project' event")
}
var i github.ProjectEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetProjectCard returns information about a current project card.
func GetProjectCard() (*github.ProjectCardEvent, error) {
if Event != EventProjectCard {
return nil, fmt.Errorf("not 'project_card' event")
}
var i github.ProjectCardEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetPublic returns information about a current public.
func GetPublic() (*github.PublicEvent, error) {
if Event != EventPublic {
return nil, fmt.Errorf("not 'public' event")
}
var i github.PublicEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetPullRequest returns information about a current pull request.
func GetPullRequest() (*github.PullRequestEvent, error) {
if Event != EventPullRequest {
return nil, fmt.Errorf("not 'pull_request' event")
}
var i github.PullRequestEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetPullRequestReview returns information about a current pull request review.
func GetPullRequestReview() (*github.PullRequestReviewEvent, error) {
if Event != EventPullRequestReview {
return nil, fmt.Errorf("not 'pull_request_review' event")
}
var i github.PullRequestReviewEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetPullRequestReviewComment returns information about a current pull request review comment.
func GetPullRequestReviewComment() (*github.PullRequestReviewCommentEvent, error) {
if Event != EventPullRequestReviewComment {
return nil, fmt.Errorf("not 'pull_request_review_comment' event")
}
var i github.PullRequestReviewCommentEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetPush returns information about a current push.
func GetPush() (*github.PushEvent, error) {
if Event != EventPush {
return nil, fmt.Errorf("not 'push' event")
}
var i github.PushEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetRelease returns information about a current release.
func GetRelease() (*github.ReleaseEvent, error) {
if Event != EventRelease {
return nil, fmt.Errorf("not 'release' event")
}
var i github.ReleaseEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetStatus returns information about a current status.
func GetStatus() (*github.StatusEvent, error) {
if Event != EventStatus {
return nil, fmt.Errorf("not 'status' event")
}
var i github.StatusEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetWatch returns information about a current watch.
func GetWatch() (*github.WatchEvent, error) {
if Event != EventWatch {
return nil, fmt.Errorf("not 'watch' event")
}
var i github.WatchEvent
err := decodeEventInfo(&i)
return &i, err
}
// GetRepositoryDispatch returns information about a current repository dispatch.
func GetRepositoryDispatch() (*github.RepositoryDispatchEvent, error) {
if Event != EventRepositoryDispatch {
return nil, fmt.Errorf("not 'repository_dispatch' event")
}
var i github.RepositoryDispatchEvent
err := decodeEventInfo(&i)
return &i, err
}
func decodeEventInfo(i interface{}) error {
f, err := os.Open(eventPath)
if err != nil {
return err
}
defer f.Close()
return json.NewDecoder(f).Decode(i)
}