-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitHubAction.pkl
707 lines (645 loc) · 25.5 KB
/
GitHubAction.pkl
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
module com.github.GitHubAction
// Definitions
// Trigger
abstract class Trigger
/// Runs your workflow anytime the branch_protection_rule event occurs. More than one activity type triggers this event.
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#branch_protection_rule
class BranchProtectionRule extends Trigger {
types: Listing<BranchProtectionRuleType>?
}
typealias BranchProtectionRuleType =
"created"
|"edited"
|"deleted"
/// Runs your workflow anytime the check_run event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/checks/runs.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#check_run
class CheckRun extends Trigger {
types: Listing<CheckRunType>?
}
typealias CheckRunType =
"created"
|"rerequested"
|"completed"
|"requested_action"
/// Runs your workflow anytime the check_suite event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/checks/suites/
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#check_suite
class CheckSuite extends Trigger {
types: Listing<CheckSuiteType>?
}
typealias CheckSuiteType =
"completed"
|"requested"
|"rerequested"
/// Runs your workflow anytime someone creates a branch or tag, which triggers the create event.
/// For information about the REST API, see https://developer.github.com/v3/git/refs/#create-a-reference.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#create
class Create extends Trigger
// Runs your workflow anytime someone deletes a branch or tag, which triggers the delete event.
/// For information about the REST API, see https://developer.github.com/v3/git/refs/#delete-a-reference.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete
class Delete extends Trigger
/// Runs your workflow anytime someone creates a deployment, which triggers the deployment event.
/// Deployments created with a commit SHA may not have a Git ref.
/// For information about the REST API, see https://developer.github.com/v3/repos/deployments/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment
class Deployment extends Trigger
/// Runs your workflow anytime a third party provides a deployment status, which triggers the deployment_status event.
/// Deployments created with a commit SHA may not have a Git ref.
/// For information about the REST API, see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment_status
class DeploymentStatus extends Trigger
/// Runs your workflow anytime the discussion event occurs. More than one activity type triggers this event.
/// For information about the GraphQL API, see https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#discussion
class Discussion extends Trigger {
types: Listing<DiscussionType>?
}
typealias DiscussionType =
"created"
|"edited"
|"deleted"
|"transferred"
|"pinned"
|"unpinned"
|"labeled"
|"unlabeled"
|"locked"
|"unlocked"
|"category_changed"
|"answered"
|"unanswered"
/// Runs your workflow anytime the discussion_comment event occurs. More than one activity type triggers this event.
/// For information about the GraphQL API, see https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#discussion_comment
class DiscussionComment extends Trigger {
types: Listing<DiscussionCommentType>?
}
typealias DiscussionCommentType =
"created"
|"edited"
|"deleted"
/// Runs your workflow anytime when someone forks a repository, which triggers the fork event.
/// For information about the REST API, see https://developer.github.com/v3/repos/forks/#create-a-fork
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#fork
class Fork extends Trigger
/// Runs your workflow when someone creates or updates a Wiki page, which triggers the gollum event.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#gollum
class Gollum extends Trigger
/// Runs your workflow anytime the issue_comment event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/issues/comments/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment
class IssueComment extends Trigger {
types: Listing<IssueCommentType>?
}
typealias IssueCommentType =
"created"
|"edited"
|"deleted"
/// Runs your workflow anytime the issues event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/issues.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues
class Issues extends Trigger {
types: Listing<IssuesType>?
}
typealias IssuesType =
"opened"
|"edited"
|"deleted"
|"transferred"
|"pinned"
|"unpinned"
|"closed"
|"reopened"
|"assigned"
|"unassigned"
|"labeled"
|"unlabeled"
|"locked"
|"unlocked"
|"milestoned"
|"demilestoned"
/// Runs your workflow anytime the label event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/issues/labels/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#label
class Label extends Trigger {
types: Listing<LabelType>?
}
typealias LabelType =
"created"
|"edited"
|"deleted"
/// Runs your workflow when a pull request is added to a merge queue, which adds the pull request to a merge group.
/// For information about the merge queue, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/merging-a-pull-request-with-a-merge-queue.
///
/// https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#merge_group
class MergeGroup extends Trigger {
types: Listing<MergeGroupType>?
}
typealias MergeGroupType =
"checked_requested"
/// Runs your workflow anytime the milestone event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/issues/milestones/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#milestone
class Milestone extends Trigger {
types: Listing<MilestoneType>?
}
typealias MilestoneType =
"created"
|"closed"
|"opened"
|"edited"
|"deleted"
/// Runs your workflow anytime someone pushes to a GitHub Pages-enabled branch, which triggers the page_build event.
/// For information about the REST API, see https://developer.github.com/v3/repos/pages/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#page_build
class PageBuild extends Trigger
/// Runs your workflow anytime the project event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/projects/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#project
class Project extends Trigger {
types: Listing<ProjectType>?
}
typealias ProjectType =
"created"
|"updated"
|"closed"
|"reopened"
|"edited"
|"deleted"
/// Runs your workflow anytime the project_card event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/projects/cards.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#project_card
class ProjectCard extends Trigger {
types: Listing<ProjectCardType>?
}
typealias ProjectCardType =
"created"
|"moved"
|"converted"
|"edited"
|"deleted"
/// Runs your workflow anytime the project_column event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/projects/columns.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#project_column
class ProjectColumn extends Trigger {
types: Listing<ProjectColumnType>?
}
typealias ProjectColumnType =
"created"
|"updated"
|"moved"
|"deleted"
/// Runs your workflow anytime someone makes a private repository public, which triggers the public event.
/// For information about the REST API, see https://developer.github.com/v3/repos/#edit.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#public
class Public extends Trigger
/// Runs your workflow anytime the pull_request event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/pulls.
/// Note: Workflows do not run on private base repositories when you open a pull request from a forked repository.
/// When you create a pull request from a forked repository to the base repository,
/// GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository.
/// Workflows don't run on forked repositories by default.
/// You must enable GitHub Actions in the Actions tab of the forked repository.
/// The permissions for the GITHUB_TOKEN in forked repositories is read-only.
/// For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
class PullRequest extends Trigger {
types: Listing<PullRequestType>?
branches: Listing<String>?
`branches-ignore`: Listing<String>?
paths: Listing<String>?
`paths-ignore`: Listing<String>?
}
typealias PullRequestType =
"assigned"
|"unassigned"
|"review_requested"
|"review_request_removed"
|"labeled"
|"unlabeled"
|"opened"
|"edited"
|"closed"
|"reopened"
|"synchronize"
|"ready_for_review"
|"locked"
|"unlocked"
|"ready_for_review"
|"converted_to_draft"
|"demilestoned"
|"milestoned"
|"review_requested"
|"review_request_removed"
|"auto_merge_enabled"
|"auto_merge_disabled"
/// Runs your workflow anytime the pull_request_review event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/pulls/reviews.
/// Note: Workflows do not run on private base repositories when you open a pull request from a forked repository.
/// When you create a pull request from a forked repository to the base repository,
/// GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository.
/// Workflows don't run on forked repositories by default.
/// You must enable GitHub Actions in the Actions tab of the forked repository.
/// The permissions for the GITHUB_TOKEN in forked repositories is read-only.
/// For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review
class PullRequestReview extends Trigger {
types: Listing<PullRequestReviewType>?
}
typealias PullRequestReviewType =
"submitted"
|"edited"
|"dismissed"
/// Runs your workflow anytime a comment on a pull request's unified diff is modified, which triggers the pull_request_review_comment event.
/// More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/pulls/comments.
/// Note: Workflows do not run on private base repositories when you open a pull request from a forked repository.
/// When you create a pull request from a forked repository to the base repository,
/// GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository.
/// Workflows don't run on forked repositories by default.
/// You must enable GitHub Actions in the Actions tab of the forked repository.
/// The permissions for the GITHUB_TOKEN in forked repositories is read-only.
/// For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment
class PullRequestReviewComment extends Trigger {
types: Listing<PullRequestReviewCommentType>?
}
typealias PullRequestReviewCommentType =
"created"
|"edited"
|"deleted"
/// This event is similar to pull_request, except that it runs in the context of the base repository of the pull request,
/// rather than in the merge commit.
/// This means that you can more safely make your secrets available to the workflows triggered by the pull request,
/// because only workflows defined in the commit on the base repository are run.
/// For example, this event allows you to create workflows that label and comment on pull requests,
/// based on the contents of the event payload.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
class PullRequestTarget extends Trigger {
types: Listing<PullRequestTargetType>?
branches: Listing<String>?
`branches-ignore`: Listing<String>?
paths: Listing<String>?
`paths-ignore`: Listing<String>?
}
typealias PullRequestTargetType =
"assigned"
|"unassigned"
|"labeled"
|"unlabeled"
|"opened"
|"edited"
|"closed"
|"reopened"
|"synchronize"
|"converted_to_draft"
|"ready_for_review"
|"locked"
|"unlocked"
|"review_requested"
|"review_request_removed"
|"auto_merge_enabled"
|"auto_merge_disabled"
/// Runs your workflow when someone pushes to a repository branch, which triggers the push event.
/// Note: The webhook payload available to GitHub Actions does not include the added, removed, and modified attributes in the commit object.
/// You can retrieve the full commit object using the REST API.
/// For more information, see https://developer.github.com/v3/repos/commits/#get-a-single-commit.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
class Push extends Trigger {
branches: Listing<String>?
`branches-ignore`: Listing<String>?
tags: Listing<String>?
`tags-ignore`: Listing<String>?
paths: Listing<String>?
`paths-ignore`: Listing<String>?
}
/// Runs your workflow anytime a package is published or updated.
/// For more information, see https://help.github.com/en/github/managing-packages-with-github-packages
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package
class RegistryPackage extends Trigger {
types: Listing<ReleaseType>?
}
typealias RegistryPackageType =
"published"
|"updated"
/// Runs your workflow anytime the release event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/repos/releases/ in the GitHub Developer documentation.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
class Release extends Trigger {
types: Listing<ReleaseType>?
}
typealias ReleaseType =
"published"
|"unpublished"
|"created"
|"edited"
|"deleted"
|"prereleased"
|"released"
/// You can use the GitHub API to trigger a webhook event called repository_dispatch
/// when you want to trigger a workflow for activity that happens outside of GitHub.
/// For more information, see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event.
/// To trigger the custom repository_dispatch webhook event, you must send a POST request to a GitHub API endpoint
/// and provide an event_type name to describe the activity type.
/// To trigger a workflow run, you must also configure your workflow to use the repository_dispatch event.
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#repository_dispatch
class RepositoryDispatch extends Trigger {
types: Listing<String>?
}
/// You can schedule a workflow to run at specific UTC times using POSIX cron syntax (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07).
/// Scheduled workflows run on the latest commit on the default or base branch.
/// The shortest interval you can run scheduled workflows is once every 5 minutes.
/// Note: GitHub Actions does not support the non-standard syntax @yearly, @monthly, @weekly, @daily, @hourly, and @reboot.
/// You can use crontab guru (https://crontab.guru/) to help generate your cron syntax and confirm what time it will run.
/// To help you get started, there is also a list of crontab guru examples (https://crontab.guru/examples.html).
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#schedule
class Schedule extends Trigger {
cron: Listing<ScheduleCron>(length > 0)
}
typealias ScheduleCron = String
/// Runs your workflow anytime the status of a Git commit changes, which triggers the status event.
/// For information about the REST API, see https://developer.github.com/v3/repos/statuses/.
///
/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#status
class Status extends Trigger
/// Runs your workflow anytime the watch event occurs. More than one activity type triggers this event.
/// For information about the REST API, see https://developer.github.com/v3/activity/starring/
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#watch
class Watch extends Trigger
/// Allows workflows to be reused by other workflows.
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_call
class WorkflowCall extends Trigger {
inputs: Mapping<String, WorkflowInput>?
outputs: Mapping<String, WorkflowCallOutput>?
secrets: Listing<WorkflowCallSecrets>?
}
class WorkflowCallOutput {
description: String?
value: Any
}
class WorkflowCallSecrets {
description: String?
required: Boolean
}
/// You can now create workflows that are manually triggered with the new workflow_dispatch event.
/// You will then see a 'Run workflow' button on the Actions tab, enabling you to easily trigger a run.
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch
class WorkflowDispatch extends Trigger {
inputs: Mapping<String, WorkflowInput>?
}
class WorkflowInput {
description: String
deprecatedMessage: String?
required: Boolean?
default: String?
type: WorkflowInputType?
options: Listing<String>?
}
typealias WorkflowInputType = "boolean"|"string"|"choice"|"environment"|"number"
/// This event occurs when a workflow run is requested or completed,
/// and allows you to execute a workflow based on the finished result of another workflow.
/// For example, if your pull_request workflow generates build artifacts,
/// you can create a new workflow that uses workflow_run to analyze the results and add a comment to the original pull request.
///
/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_run
class WorkflowRun extends Trigger {
types: Listing<WorkflowRunType>?
workflows: Listing<String>(length > 0)
branches: Listing<String>?
`branches-ignore`: Listing<String>?
}
typealias WorkflowRunType =
"requested"
|"completed"
|"in_progress"
// On
class On {
branch_protection_rule: BranchProtectionRule?
check_run: CheckRun?
check_suite: CheckSuite?
create: Create?
`delete`: Delete?
deployment: Deployment?
deployment_status: DeploymentStatus?
discussion: Discussion?
discussion_comment: DiscussionComment?
fork: Fork?
gollum: Gollum?
issue_comment: IssueComment?
issues: Issues?
label: Label?
merge_group: MergeGroup?
milestone: Milestone?
page_build: PageBuild?
project: Project?
project_card: ProjectCard?
project_column: ProjectColumn?
public: Public?
pull_request: PullRequest?
pull_request_review: PullRequestReview?
pull_request_review_comment: PullRequestReviewComment?
pull_request_target: PullRequestTarget?
push: Push?
registry_package: RegistryPackage?
release: Release?
repository_dispatch: RepositoryDispatch?
schedule: Schedule?
status: Status?
watch: Watch?
workflow_call: WorkflowCall?
workflow_dispatch: WorkflowDispatch?
workflow_run: WorkflowRun?
}
// Environment Variables
typealias EnvironmentVariables = Mapping<String, String|Boolean|Number>
// Permissions
class Permissions {
actions: Permission?
checks: Permission?
contents: Permission?
deployments: Permission?
`id-token`: Permission?
issues: Permission?
discussions: Permission?
packages: Permission?
pages: Permission?
`pull-requests`: Permission?
`repository-projects`: Permission?
`security-events`: Permission?
statuses: Permission?
}
typealias Permission = "read"|"write"|"none"
// Concurrency
class Concurrency {
group: String
`cancel-in-progress`: Boolean
}
// Jobs
abstract class BaseJob {
name: String?
`if`: String?
needs: (String|*Listing<String>)?
concurrency: Concurrency?
strategy: Strategy?
permissions: (*Permissions|"read-all"|"write-all")?
}
class DefaultJob extends BaseJob {
`runs-on`: *String|Machine|Listing<*String|Machine>
`timeout-minutes`: Number?
env: EnvironmentVariables?
outputs: Mapping<String, String>?
environment: (*Environment|String)?
steps: Listing<Step>(stepsHasOnlyRunOrUses(this))
}
class ReusableJob extends BaseJob {
uses: String(matches(Regex("(.+\\/)+(.+)\\.(ya?ml)(@.+)?")))?
with: Mapping<String, String|Number|Boolean>?
secrets: ("inherit"|*Mapping<String, String|Number|Boolean>)?
}
typealias Job = *DefaultJob|ReusableJob
// Machines, part of Jobs
abstract class Machine {
name: String
}
class UbuntuLatest extends Machine {
name = "ubuntu-latest"
}
class MacOsLatest extends Machine {
name = "macos-latest"
}
class WindowsLatest extends Machine {
name = "windows-latest"
}
// Strategy, part of Jobs
class Strategy {
matrix: Mapping<String, Listing<String|*Dynamic>>
`fail-fast`: Boolean?
`max-parallel`: (Number|String)?
}
// Environment, part of Jobs
class Environment {
name: String
url: String?
}
// Step, part of Jobs
class Step {
name: String?
id: String?
`if`: String?
`timeout-minutes`: Number?
env: EnvironmentVariables?
`working-directory`: String?
shell: Shell?
run: String?
uses: String?
with: Mapping<String, String|Number|Boolean>?
}
// Shell, part of Steps
typealias Shell = "pwsh"|"bash"|"sh"|"cmd"|"powershell"|"python"
// Jobs top-level typealias
typealias Jobs = Mapping<String, Job>(
length > 0,
keys.any((key) -> key.matches(Regex("[a-zA-Z_][a-zA-Z0-9_-]*")))
)
// Templating
name: String
local const onIsSet = (on: On) ->
on.branch_protection_rule != null ||
on.check_run != null ||
on.check_suite != null ||
on.create != null ||
on.`delete` != null ||
on.deployment != null ||
on.deployment_status != null ||
on.discussion != null ||
on.discussion_comment != null ||
on.fork != null ||
on.gollum != null ||
on.issue_comment != null ||
on.issues != null ||
on.label != null ||
on.merge_group != null ||
on.milestone != null ||
on.page_build != null ||
on.project != null ||
on.project_card != null ||
on.project_column != null ||
on.public != null ||
on.pull_request != null ||
on.pull_request_review != null ||
on.pull_request_review_comment != null ||
on.pull_request_target != null ||
on.push != null ||
on.registry_package != null ||
on.release != null ||
on.repository_dispatch != null ||
on.schedule != null ||
on.status != null ||
on.watch != null ||
on.workflow_call != null ||
on.workflow_dispatch != null ||
on.workflow_run != null
on: On(onIsSet)
env: EnvironmentVariables?
concurrency: Concurrency?
permissions: (*Permissions|"read-all"|"write-all")?
jobs: Jobs
// Output
local jsonRenderer = new JsonRenderer {}
output {
text = "# Do not modify!\n# This file was generated from a template using https://github.com/StefMa/pkl-gha\n\n\(super.text)"
renderer = new YamlRenderer {
converters {
["runs-on"] = (runsOn: String|Machine|Listing<String|Machine>) ->
if (runsOn is Listing<String|Machine>) convertMachinesToString(runsOn) else convertMachineToString(runsOn)
["schedule"] = (schedule: Schedule?) -> schedule.ifNonNull((_) ->
schedule.cron.toList().map((cr) -> Map("cron", new RenderDirective { text = " " + jsonRenderer.renderValue(cr) }))
)
}
}
}
const local function stepsHasOnlyRunOrUses(steps: Listing<Step>): Boolean = steps
.toList()
.every((step) -> !(containsRunAndUses(step) || containsNeitherRunNorUses(step)))
const local function containsRunAndUses(step: Step): Boolean = step.run != null && step.uses != null
const local function containsNeitherRunNorUses(step: Step): Boolean = step.run == null && step.uses == null
const local function convertMachinesToString(runsOn: Listing<String|Machine>): Listing<String> = runsOn
.toList()
.map((type) -> convertMachineToString(type))
.toListing()
const local function convertMachineToString(machine: String|Machine): String =
if (machine is Machine) machine.name else machine