forked from rhysd/actionlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.go
782 lines (703 loc) · 29.5 KB
/
ast.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
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
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
package actionlint
import (
"fmt"
"strconv"
"strings"
"gopkg.in/yaml.v3"
)
// Pos represents position in the file.
type Pos struct {
// Line is a line number of the position. This value is 1-based.
Line int
// Col is a column number of the position. This value is 1-based.
Col int
}
func (p *Pos) String() string {
return fmt.Sprintf("line:%d,col:%d", p.Line, p.Col)
}
// String represents generic string value in YAML file with position.
type String struct {
// Value is a raw value of the string.
Value string
// Quoted represents the string is quoted with ' or " in the YAML source.
Quoted bool
// Pos is a position of the string in source.
Pos *Pos
}
// Bool represents generic boolean value in YAML file with position.
type Bool struct {
// Value is a raw value of the bool string.
Value bool
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
// Pos is a position in source.
Pos *Pos
}
// Int represents generic integer value in YAML file with position.
type Int struct {
// Value is a raw value of the integer string.
Value int
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
// Pos is a position in source.
Pos *Pos
}
// Float represents generic float value in YAML file with position.
type Float struct {
// Value is a raw value of the float string.
Value float64
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
// Pos is a position in source.
Pos *Pos
}
// Event interface represents workflow events in 'on' section
type Event interface {
// EventName returns name of the event to trigger this workflow.
EventName() string
}
// WebhookEvent represents event type based on webhook events.
// Some events can't have 'types' field. Only 'push' and 'pull' events can have 'tags', 'tags-ignore',
// 'paths' and 'paths-ignore' fields. Only 'workflow_run' event can have 'workflows' field.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onevent_nametypes
type WebhookEvent struct {
// Hook is a name of the webhook event.
Hook *String
// Types is list of types of the webhook event. Only the types enumerated here will trigger
// the workflow.
Types []*String
// Branches is list of branch filters to choose branches.
Branches []*String
// BranchesIgnore is list of branch filters to reject some branches.
BranchesIgnore []*String
// Tags is list of tag filters to choose tags.
Tags []*String
// TagsIgnore is list of tag filters to reject some tags.
TagsIgnore []*String
// Paths is list of path filters to choose file paths.
Paths []*String
// PathsIgnore is list of path filters to reject some file paths.
PathsIgnore []*String
// Workflows is list of workflow names which are triggered by 'workflow_run' event.
Workflows []*String
// Pos is a position in source.
Pos *Pos
}
// EventName returns name of the event to trigger this workflow.
func (e *WebhookEvent) EventName() string {
return e.Hook.Value
}
// ScheduledEvent is event scheduled by workflow.
// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#scheduled-events
type ScheduledEvent struct {
// Cron is list of cron strings which schedules workflow.
Cron []*String
// Pos is a position in source.
Pos *Pos
}
// EventName returns name of the event to trigger this workflow.
func (e *ScheduledEvent) EventName() string {
return "schedule"
}
// DispatchInput is input specified on dispatching workflow manually.
// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch
type DispatchInput struct {
// Name is a name of input value specified on dispatching workflow manually.
Name *String
// Description is a description of input value specified on dispatching workflow manually.
Description *String
// Required is a flag to show if this input is mandatory or not on dispatching workflow manually.
Required *Bool
// Default is a default value of input value on dispatching workflow manually.
Default *String
}
// WorkflowDispatchEvent is event on dispatching workflow manually.
// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch
type WorkflowDispatchEvent struct {
// Inputs is map from input names to input attributes.
Inputs map[string]*DispatchInput
// Pos is a position in source.
Pos *Pos
}
// EventName returns name of the event to trigger this workflow.
func (e *WorkflowDispatchEvent) EventName() string {
return "workflow_dispatch"
}
// RepositoryDispatchEvent is repository_dispatch event configuration.
// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#repository_dispatch
type RepositoryDispatchEvent struct {
// Types is list of types which can trigger workflow.
Types []*String
// Pos is a position in source.
Pos *Pos
}
// EventName returns name of the event to trigger this workflow.
func (e *RepositoryDispatchEvent) EventName() string {
return "repository_dispatch"
}
// WorkflowCallEventInputType is a type of inputs at workflow_call event.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinput_idtype
type WorkflowCallEventInputType uint8
const (
// WorkflowCallEventInputTypeInvalid represents invalid type input as default value of the type.
WorkflowCallEventInputTypeInvalid WorkflowCallEventInputType = iota
// WorkflowCallEventInputTypeBoolean represents boolean type input.
WorkflowCallEventInputTypeBoolean
// WorkflowCallEventInputTypeNumber represents number type input.
WorkflowCallEventInputTypeNumber
// WorkflowCallEventInputTypeString represents string type input.
WorkflowCallEventInputTypeString
)
// WorkflowCallEventInput is an input configuration of workflow_call event.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
type WorkflowCallEventInput struct {
// Description is a description of the input.
Description *String
// Default is a default value of the input. Nil means no default value.
Default *String
// Required represents if the input is required or optional. When this value is nil, it means optional.
Required *Bool
// Type of the input, which must be one of 'boolean', 'number' or 'string'. This property is required.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinput_idtype
Type WorkflowCallEventInputType
}
// WorkflowCallEventSecret is a secret configuration of workflow_call event.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecrets
type WorkflowCallEventSecret struct {
// Description is a description of the secret.
Description *String
// Required represents if the secret is required or optional. When this value is nil, it means optional.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_idrequired
Required *Bool
}
// WorkflowCallEvent is workflow_call event configuration.
// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow-reuse-events
type WorkflowCallEvent struct {
// Inputs is a map from input name to input configuration.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
Inputs map[*String]*WorkflowCallEventInput
// Secrets is a map from name of secret to secret configuration.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecrets
Secrets map[*String]*WorkflowCallEventSecret
// Pos is a position in source.
Pos *Pos
}
// EventName returns name of the event to trigger this workflow.
func (e *WorkflowCallEvent) EventName() string {
return "workflow_call"
}
// PermissionScope is struct for respective permission scope like "issues", "checks", ...
// https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
type PermissionScope struct {
// Name is name of the scope.
Name *String
// Value is permission value of the scope.
Value *String
}
// Permissions is set of permission configurations in workflow file. All permissions can be set at
// once. Or each permission can be configured respectively.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#permissions
type Permissions struct {
// All represents a permission value for all the scopes at once.
All *String
// Scopes is mappings from scope name to its permission configuration
Scopes map[string]*PermissionScope
// Pos is a position in source.
Pos *Pos
}
// DefaultsRun is configuration that shell is how to be run.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#defaultsrun
type DefaultsRun struct {
// Shell is shell name to be run.
Shell *String
// WorkingDirectory is a default working directory path.
WorkingDirectory *String
// Pos is a position in source.
Pos *Pos
}
// Defaults is set of default configurations to run shell.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#defaults
type Defaults struct {
// Run is configuration of how to run shell.
Run *DefaultsRun
// Pos is a position in source.
Pos *Pos
}
// Concurrency is a configuration of concurrency of the workflow.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency
type Concurrency struct {
// Group is name of the concurrency group.
Group *String
// CancelInProgress is a flag that shows if canceling this workflow cancels other jobs in progress.
CancelInProgress *Bool
// Pos is a position in source.
Pos *Pos
}
// Environment is a configuration of environment.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idenvironment
type Environment struct {
// Name is a name of environment which the workflow uses.
Name *String
// URL is the URL mapped to 'environment_url' in the deployments API. Empty value means no value was specified.
URL *String
// Pos is a position in source.
Pos *Pos
}
// ExecKind is kind of how the step is executed. A step runs some action or runs some shell script.
type ExecKind uint8
const (
// ExecKindAction is kind for step to run action
ExecKindAction ExecKind = iota
// ExecKindRun is kind for step to run shell script
ExecKindRun
)
// Exec is an interface how the step is executed. Step in workflow runs either an action or a script
type Exec interface {
// Kind returns kind of the step execution.
Kind() ExecKind
// SetWorkingDir sets working-directory section.
SetWorkingDir(d *String)
}
// ExecRun is configuration how to run shell script at the step.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsrun
type ExecRun struct {
// Run is script to run.
Run *String
// Shell represents optional 'shell' field. Nil means nothing specified.
Shell *String
// WorkingDirectory represents optional 'working-directory' field. Nil means nothing specified.
WorkingDirectory *String
// RunPos is position of 'run' section
RunPos *Pos
}
// Kind returns kind of the step execution.
func (e *ExecRun) Kind() ExecKind {
return ExecKindRun
}
// SetWorkingDir sets working-directory section.
func (e *ExecRun) SetWorkingDir(dir *String) {
e.WorkingDirectory = dir
}
// Input is an input field for running an action.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswith
type Input struct {
// Name is a name of the input.
Name *String
// Value is a value of the input.
Value *String
}
// ExecAction is configuration how to run action at the step.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses
type ExecAction struct {
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses
Uses *String
// Inputs represents inputs to the action to execute in 'with' section
Inputs map[string]*Input
// Entrypoint represents optional 'entrypoint' field in 'with' section. Nil field means nothing specified
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithentrypoint
Entrypoint *String
// Args represents optional 'args' field in 'with' section. Nil field means nothing specified
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs
Args *String
// WorkingDirectory is a default working directory path to run action
WorkingDirectory *String
}
// Kind returns kind of the step execution.
func (e *ExecAction) Kind() ExecKind {
return ExecKindAction
}
// SetWorkingDir sets working-directory section.
func (e *ExecAction) SetWorkingDir(dir *String) {
e.WorkingDirectory = dir
}
// RawYAMLValueKind is kind of raw YAML values
type RawYAMLValueKind int
const (
// RawYAMLValueKindObject is kind for an object value of raw YAML value.
RawYAMLValueKindObject = RawYAMLValueKind(yaml.MappingNode)
// RawYAMLValueKindArray is kind for an array value of raw YAML value.
RawYAMLValueKindArray = RawYAMLValueKind(yaml.SequenceNode)
// RawYAMLValueKindString is kind for a string value of raw YAML value.
RawYAMLValueKindString = RawYAMLValueKind(yaml.ScalarNode)
)
// RawYAMLValue is a value at matrix variation. Any value can be put at matrix variations
// including mappings and arrays.
type RawYAMLValue interface {
// Kind returns kind of raw YAML value.
Kind() RawYAMLValueKind
// Equals returns if the other value is equal to the value.
Equals(other RawYAMLValue) bool
// Pos returns the start position of the value in the source file
Pos() *Pos
// String returns string representation of the value
String() string
}
// RawYAMLObject is raw YAML mapping value.
type RawYAMLObject struct {
// Props is map from property names to their values.
Props map[string]RawYAMLValue
pos *Pos
}
// Kind returns kind of raw YAML value.
func (o *RawYAMLObject) Kind() RawYAMLValueKind {
return RawYAMLValueKindObject
}
// Equals returns if the other value is equal to the value.
func (o *RawYAMLObject) Equals(other RawYAMLValue) bool {
switch other := other.(type) {
case *RawYAMLObject:
for n, p1 := range o.Props {
if p2, ok := other.Props[n]; !ok || !p1.Equals(p2) {
return false
}
}
return true
default:
return false
}
}
// Pos returns the start position of the value in the source file
func (o *RawYAMLObject) Pos() *Pos {
return o.pos
}
func (o *RawYAMLObject) String() string {
qs := make([]string, 0, len(o.Props))
for n, p := range o.Props {
qs = append(qs, fmt.Sprintf("%q: %s", n, p.String()))
}
return fmt.Sprintf("{%s}", strings.Join(qs, ", "))
}
// RawYAMLArray is raw YAML sequence value.
type RawYAMLArray struct {
// Elems is list of elements of the array value.
Elems []RawYAMLValue
pos *Pos
}
// Kind returns kind of raw YAML value.
func (a *RawYAMLArray) Kind() RawYAMLValueKind {
return RawYAMLValueKindArray
}
// Equals returns if the other value is equal to the value.
func (a *RawYAMLArray) Equals(other RawYAMLValue) bool {
switch other := other.(type) {
case *RawYAMLArray:
if len(a.Elems) != len(other.Elems) {
return false
}
for i, e1 := range a.Elems {
if !e1.Equals(other.Elems[i]) {
return false
}
}
return true
default:
return false
}
}
// Pos returns the start position of the value in the source file
func (a *RawYAMLArray) Pos() *Pos {
return a.pos
}
func (a *RawYAMLArray) String() string {
qs := make([]string, 0, len(a.Elems))
for _, v := range a.Elems {
qs = append(qs, v.String())
}
return fmt.Sprintf("[%s]", strings.Join(qs, ", "))
}
// RawYAMLString is raw YAML scalar value.
type RawYAMLString struct {
// Note: Might be useful to add kind to check the string value is int/float/bool/null.
// Value is string representation of the scalar node.
Value string
pos *Pos
}
// Kind returns kind of raw YAML value.
func (s *RawYAMLString) Kind() RawYAMLValueKind {
return RawYAMLValueKindString
}
// Equals returns if the other value is equal to the value.
func (s *RawYAMLString) Equals(other RawYAMLValue) bool {
switch other := other.(type) {
case *RawYAMLString:
return s.Value == other.Value
default:
return false
}
}
// Pos returns the start position of the value in the source file
func (s *RawYAMLString) Pos() *Pos {
return s.pos
}
func (s *RawYAMLString) String() string {
return strconv.Quote(s.Value)
}
// MatrixRow is one row of matrix. One matrix row can take multiple values. Those variations are
// stored as row of values in this struct.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
type MatrixRow struct {
// Name is a name of matrix value.
Name *String
// Values is variations of values which the matrix value can take.
Values []RawYAMLValue
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
}
// MatrixAssign represents which value should be taken in the row of the matrix.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
type MatrixAssign struct {
// Key is a name of the matrix value.
Key *String
// Value is the value selected from values in row.
Value RawYAMLValue
}
// MatrixCombination is combination of matrix value assignments to define one of matrix variations.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
type MatrixCombination struct {
Assigns map[string]*MatrixAssign
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
}
// MatrixCombinations is list of combinations of matrix assignments used for 'include' and 'exclude'
// sections.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
type MatrixCombinations struct {
Combinations []*MatrixCombination
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
}
// ContainsExpression returns if the combinations section includes at least one expression node.
func (cs *MatrixCombinations) ContainsExpression() bool {
if cs.Expression != nil {
return true
}
for _, c := range cs.Combinations {
if c.Expression != nil {
return true
}
}
return false
}
// Matrix is matrix variations configuration of a job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
type Matrix struct {
// Values stores mappings from name to values.
Rows map[string]*MatrixRow
// Include is list of combinations of matrix values and additional values on running matrix combinations.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
Include *MatrixCombinations
// Exclude is list of combinations of matrix values which should not be run. Combinations in
// this list will be removed from combinations of matrix to run.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-excluding-configurations-from-a-matrix
Exclude *MatrixCombinations
// Expression is a string when expression syntax ${{ }} is used for this section.
Expression *String
// Pos is a position in source.
Pos *Pos
}
// Strategy is strategy configuration of how the job is run.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategy
type Strategy struct {
// Matrix is matrix of combinations of values. Each combination will run the job once.
Matrix *Matrix
// FailFast is flag to show if other jobs should stop when one job fails.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
FailFast *Bool
// MaxParallel is how many jobs should be run at once.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel
MaxParallel *Int
// Pos is a position in source.
Pos *Pos
}
// EnvVar represents key-value of environment variable setup.
type EnvVar struct {
// Name is name of the environment variable.
Name *String
// Value is string value of the environment variable.
Value *String
}
// Env represents set of environment variables.
type Env struct {
// Vars is mapping from env var name to env var value.
Vars map[string]*EnvVar
// Expression is an expression string which contains ${{ ... }}. When this value is not empty,
// Vars should be nil.
Expression *String
}
// Step is step configuration. Step runs one action or one shell script.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps
type Step struct {
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsid
ID *String
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsif
If *String
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsname
Name *String
Exec Exec
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsenv
Env *Env
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error
ContinueOnError *Bool
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes
TimeoutMinutes *Float
// Pos is a position in source.
Pos *Pos
}
// Credentials is credentials configuration.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainercredentials
type Credentials struct {
// Username is username for authentication.
Username *String
// Password is password for authentication.
Password *String
// Pos is a position in source.
Pos *Pos
}
// Container is configuration of how to run the container.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainer
type Container struct {
// Image is specification of Docker image.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerimage
Image *String
// Credentials is credentials configuration of the Docker container.
Credentials *Credentials
// Env is environment variables setup in the container.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerenv
Env *Env
// Ports is list of port number mappings of the container.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerports
Ports []*String
// Volumes are list of volumes to be mounted to the container.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes
Volumes []*String
// Options is options string to run the container.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontaineroptions
Options *String
// Pos is a position in source.
Pos *Pos
}
// Service is configuration to run a service like database.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idservices
type Service struct {
// Name is name of the service.
Name *String
// Container is configuration of container which runs the service.
Container *Container
}
// Output is output entry of the job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs
type Output struct {
// Name is name of output.
Name *String
// Value is value of output.
Value *String
}
// Runner is struct for runner configuration.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
type Runner struct {
// Labels is list label names to select a runner to run a job. There are preset labels and user
// defined labels. Runner matching to the labels is selected.
Labels []*String
}
// WorkflowCallInput is a normal input for workflow call.
type WorkflowCallInput struct {
// Name is a name of the input.
Name *String
// Value is a value of the input.
Value *String
}
// WorkflowCallSecret is a secret input for workflow call.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idwith
type WorkflowCallSecret struct {
// Name is a name of the secret
Name *String
// Value is a value of the secret
Value *String
}
// WorkflowCall is a struct to represent workflow call at jobs.<job_id>.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
type WorkflowCall struct {
// Uses is a workflow specification to be called. This field is mandatory.
Uses *String
// Inputs is a map from input name to input value at 'with:'.
Inputs map[string]*WorkflowCallInput
// Secrets is a map from secret name to secret value at 'secrets:'.
Secrets map[string]*WorkflowCallSecret
}
// Job is configuration of how to run a job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobs
type Job struct {
// ID is an ID of the job, which is key of job configuration objects.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_id
ID *String
// Name is a name of job that user can specify freely.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idname
Name *String
// Needs is list of job IDs which should be run before running this job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds
Needs []*String
// RunsOn is runner configuration which run the job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
RunsOn *Runner
// Permissions is permission configuration for running the job.
Permissions *Permissions
// Environment is environment specification where the job runs.
Environment *Environment
// Concurrency is concurrency configuration on running the job.
Concurrency *Concurrency
// Outputs is map from output name to output specifications.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs
Outputs map[string]*Output
// Env is environment variables setup while running the job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idenv
Env *Env
// Defaults is default configurations of how to run scripts.
Defaults *Defaults
// If is a condition whether this job should be run.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idif
If *String
// Steps is list of steps to be run in the job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps
Steps []*Step
// TimeoutMinutes is timeout value of running the job in minutes.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes
TimeoutMinutes *Float
// Strategy is strategy configuration of running the job.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategy
Strategy *Strategy
// ContinueOnError is a flag to show if execution should continue on error.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
ContinueOnError *Bool
// Container is container configuration to run the job.
Container *Container
// Services is map from service names to service configurations.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idservices
Services map[string]*Service
// WorkflowCall is a workflow call by 'uses:'.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
WorkflowCall *WorkflowCall
// Pos is a position in source.
Pos *Pos
}
// Workflow is root of workflow syntax tree, which represents one workflow configuration file.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
type Workflow struct {
// Name is name of the workflow. This field can be nil when user didn't specify the name explicitly.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#name
Name *String
// On is list of events which can trigger this workflow.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
On []Event
// Permissions is configuration of permissions of this workflow.
Permissions *Permissions
// Env is a default set of environment variables while running this workflow.
// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#env
Env *Env
// Defaults is default configuration of how to run scripts.
Defaults *Defaults
// Concurrency is concurrency configuration of entire workflow. Each jobs also can their own
// concurrency configurations.
Concurrency *Concurrency
// Jobs is mappings from job ID to the job object
Jobs map[string]*Job
}