-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-action.ts
414 lines (413 loc) · 12.3 KB
/
get-action.ts
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
import {
BranchProtectionRuleEvent,
CheckRunEvent,
CheckSuiteEvent,
CodeScanningAlertEvent,
CommitCommentEvent,
CreateEvent,
DeleteEvent,
DependabotAlertEvent,
DeployKeyEvent,
DeploymentEvent,
DeploymentReviewEvent,
DeploymentStatusEvent,
DiscussionCommentEvent,
DiscussionEvent,
ForkEvent,
GithubAppAuthorizationEvent,
GollumEvent,
InstallationEvent,
InstallationRepositoriesEvent,
IssueCommentEvent,
IssuesEvent,
LabelEvent,
MarketplacePurchaseEvent,
MemberEvent,
MembershipEvent,
MergeGroupEvent,
MetaEvent,
MilestoneEvent,
OrgBlockEvent,
OrganizationEvent,
PackageEvent,
PageBuildEvent,
PingEvent,
ProjectCardEvent,
ProjectColumnEvent,
ProjectEvent,
ProjectsV2ItemEvent,
PublicEvent,
PullRequestEvent,
PullRequestReviewCommentEvent,
PullRequestReviewEvent,
PullRequestReviewThreadEvent,
PushEvent,
ReleaseEvent,
RepositoryDispatchEvent,
RepositoryEvent,
RepositoryImportEvent,
RepositoryVulnerabilityAlertEvent,
Schema,
SecurityAdvisoryEvent,
SponsorshipEvent,
StarEvent,
StatusEvent,
TeamAddEvent,
TeamEvent,
WatchEvent,
WorkflowDispatchEvent,
WorkflowJobEvent,
WorkflowRunEvent,
} from '@octokit/webhooks-types'
import { BranchProtectionRuleAction } from './actions/branch-protection-rule'
import { CheckRunAction } from './actions/check-run'
import { CheckSuiteAction } from './actions/check-suite'
import { CodeScanningAlertAction } from './actions/code-scanning-alert'
import { CommitCommentAction } from './actions/commit-comment'
import { CreateAction } from './actions/create'
import { DeleteAction } from './actions/delete'
import { DependabotAlertAction } from './actions/dependabot-alert'
import { DeployKeyAction } from './actions/deploy-key'
import { DeploymentAction } from './actions/deployment'
import { DeploymentReviewAction } from './actions/deployment-review'
import { DeploymentStatusAction } from './actions/deployment-status'
import { DiscussionAction } from './actions/discussion'
import { DiscussionCommentAction } from './actions/discussion-comment'
import { ForkAction } from './actions/fork'
import { GithubAppAuthorizationAction } from './actions/github-app-authorization'
import { GollumAction } from './actions/gollum'
import { InstallationAction } from './actions/installation'
import { InstallationRepositoriesAction } from './actions/installation-repositories'
import { IssueCommentAction } from './actions/issue-comment'
import { IssuesAction } from './actions/issues'
import { LabelAction } from './actions/label'
import { MarketplacePurchaseAction } from './actions/marketplace-purchase'
import { MemberAction } from './actions/member'
import { MembershipAction } from './actions/membership'
import { MergeGroupAction } from './actions/merge-group'
import { MetaAction } from './actions/meta'
import { MilestoneAction } from './actions/milestone'
import { OrganizationAction } from './actions/organization'
import { OrgBlockAction } from './actions/org-block'
import { PackageAction } from './actions/package'
import { PageBuildAction } from './actions/page-build'
import { PingAction } from './actions/ping'
import { ProjectAction } from './actions/project'
import { ProjectCardAction } from './actions/project-card'
import { ProjectColumnAction } from './actions/project-column'
import { ProjectsV2ItemAction } from './actions/projects-v2-item'
import { PublicAction } from './actions/public'
import { PullRequestAction } from './actions/pull-request'
import { PullRequestReviewAction } from './actions/pull-request-review'
import { PullRequestReviewCommentAction } from './actions/pull-request-review-comment'
import { PullRequestReviewThreadAction } from './actions/pull-request-review-thread'
import { PushAction } from './actions/push'
import { ReleaseAction } from './actions/release'
import { RepositoryDispatchAction } from './actions/repository-dispatch'
import { RepositoryAction } from './actions/repository'
import { RepositoryImportAction } from './actions/repository-import'
import { RepositoryVulnerabilityAlertAction } from './actions/repository-vulnerability-alert'
import { SecurityAdvisoryAction } from './actions/security-advisory'
import { SponsorshipAction } from './actions/sponsorship'
import { StarAction } from './actions/star'
import { StatusAction } from './actions/status'
import { TeamAction } from './actions/team'
import { TeamAddAction } from './actions/team-add'
import { WatchAction } from './actions/watch'
import { WorkflowDispatchAction } from './actions/workflow-dispatch'
import { WorkflowJobAction } from './actions/workflow-job'
import { WorkflowRunAction } from './actions/workflow-run'
import { Discord } from '@book000/node-utils'
export function getAction(discord: Discord, eventName: string, event: Schema) {
switch (eventName) {
case 'branch_protection_rule': {
return new BranchProtectionRuleAction(
discord,
eventName,
event as BranchProtectionRuleEvent
)
}
case 'check_run': {
return new CheckRunAction(discord, eventName, event as CheckRunEvent)
}
case 'check_suite': {
return new CheckSuiteAction(discord, eventName, event as CheckSuiteEvent)
}
case 'code_scanning_alert': {
return new CodeScanningAlertAction(
discord,
eventName,
event as CodeScanningAlertEvent
)
}
case 'commit_comment': {
return new CommitCommentAction(
discord,
eventName,
event as CommitCommentEvent
)
}
case 'create': {
return new CreateAction(discord, eventName, event as CreateEvent)
}
case 'delete': {
return new DeleteAction(discord, eventName, event as DeleteEvent)
}
case 'dependabot_alert': {
return new DependabotAlertAction(
discord,
eventName,
event as DependabotAlertEvent
)
}
case 'deploy_key': {
return new DeployKeyAction(discord, eventName, event as DeployKeyEvent)
}
case 'deployment_review': {
return new DeploymentReviewAction(
discord,
eventName,
event as DeploymentReviewEvent
)
}
case 'deployment_status': {
return new DeploymentStatusAction(
discord,
eventName,
event as DeploymentStatusEvent
)
}
case 'deployment': {
return new DeploymentAction(discord, eventName, event as DeploymentEvent)
}
case 'discussion_comment': {
return new DiscussionCommentAction(
discord,
eventName,
event as DiscussionCommentEvent
)
}
case 'discussion': {
return new DiscussionAction(discord, eventName, event as DiscussionEvent)
}
case 'fork': {
return new ForkAction(discord, eventName, event as ForkEvent)
}
case 'github_app_authorization': {
return new GithubAppAuthorizationAction(
discord,
eventName,
event as GithubAppAuthorizationEvent
)
}
case 'gollum': {
return new GollumAction(discord, eventName, event as GollumEvent)
}
case 'installation_repositories': {
return new InstallationRepositoriesAction(
discord,
eventName,
event as InstallationRepositoriesEvent
)
}
case 'installation': {
return new InstallationAction(
discord,
eventName,
event as InstallationEvent
)
}
case 'issue_comment': {
return new IssueCommentAction(
discord,
eventName,
event as IssueCommentEvent
)
}
case 'issues': {
return new IssuesAction(discord, eventName, event as IssuesEvent)
}
case 'label': {
return new LabelAction(discord, eventName, event as LabelEvent)
}
case 'marketplace_purchase': {
return new MarketplacePurchaseAction(
discord,
eventName,
event as MarketplacePurchaseEvent
)
}
case 'member': {
return new MemberAction(discord, eventName, event as MemberEvent)
}
case 'membership': {
return new MembershipAction(discord, eventName, event as MembershipEvent)
}
case 'merge_group': {
return new MergeGroupAction(discord, eventName, event as MergeGroupEvent)
}
case 'meta': {
return new MetaAction(discord, eventName, event as MetaEvent)
}
case 'milestone': {
return new MilestoneAction(discord, eventName, event as MilestoneEvent)
}
case 'org_block': {
return new OrgBlockAction(discord, eventName, event as OrgBlockEvent)
}
case 'organization': {
return new OrganizationAction(
discord,
eventName,
event as OrganizationEvent
)
}
case 'package': {
return new PackageAction(discord, eventName, event as PackageEvent)
}
case 'page_build': {
return new PageBuildAction(discord, eventName, event as PageBuildEvent)
}
case 'ping': {
return new PingAction(discord, eventName, event as PingEvent)
}
case 'project_card': {
return new ProjectCardAction(
discord,
eventName,
event as ProjectCardEvent
)
}
case 'project_column': {
return new ProjectColumnAction(
discord,
eventName,
event as ProjectColumnEvent
)
}
case 'project': {
return new ProjectAction(discord, eventName, event as ProjectEvent)
}
case 'projects_v2_item': {
return new ProjectsV2ItemAction(
discord,
eventName,
event as ProjectsV2ItemEvent
)
}
case 'public': {
return new PublicAction(discord, eventName, event as PublicEvent)
}
case 'pull_request_review_comment': {
return new PullRequestReviewCommentAction(
discord,
eventName,
event as PullRequestReviewCommentEvent
)
}
case 'pull_request_review_thread': {
return new PullRequestReviewThreadAction(
discord,
eventName,
event as PullRequestReviewThreadEvent
)
}
case 'pull_request_review': {
return new PullRequestReviewAction(
discord,
eventName,
event as PullRequestReviewEvent
)
}
case 'pull_request': {
return new PullRequestAction(
discord,
eventName,
event as PullRequestEvent
)
}
case 'push': {
return new PushAction(discord, eventName, event as PushEvent)
}
case 'release': {
return new ReleaseAction(discord, eventName, event as ReleaseEvent)
}
case 'repository_dispatch': {
return new RepositoryDispatchAction(
discord,
eventName,
event as RepositoryDispatchEvent
)
}
case 'repository_import': {
return new RepositoryImportAction(
discord,
eventName,
event as RepositoryImportEvent
)
}
case 'repository_vulnerability_alert': {
return new RepositoryVulnerabilityAlertAction(
discord,
eventName,
event as RepositoryVulnerabilityAlertEvent
)
}
case 'repository': {
return new RepositoryAction(discord, eventName, event as RepositoryEvent)
}
case 'security_advisory': {
return new SecurityAdvisoryAction(
discord,
eventName,
event as SecurityAdvisoryEvent
)
}
case 'sponsorship': {
return new SponsorshipAction(
discord,
eventName,
event as SponsorshipEvent
)
}
case 'star': {
return new StarAction(discord, eventName, event as StarEvent)
}
case 'status': {
return new StatusAction(discord, eventName, event as StatusEvent)
}
case 'team_add': {
return new TeamAddAction(discord, eventName, event as TeamAddEvent)
}
case 'team': {
return new TeamAction(discord, eventName, event as TeamEvent)
}
case 'watch': {
return new WatchAction(discord, eventName, event as WatchEvent)
}
case 'workflow_dispatch': {
return new WorkflowDispatchAction(
discord,
eventName,
event as WorkflowDispatchEvent
)
}
case 'workflow_job': {
return new WorkflowJobAction(
discord,
eventName,
event as WorkflowJobEvent
)
}
case 'workflow_run': {
return new WorkflowRunAction(
discord,
eventName,
event as WorkflowRunEvent
)
}
default: {
throw new Error(`Unsupported event: ${eventName}`)
}
}
}