@@ -97,6 +97,19 @@ type RequiredStatusChecksRuleParameters struct {
97
97
StrictRequiredStatusChecksPolicy bool `json:"strict_required_status_checks_policy"`
98
98
}
99
99
100
+ // RuleRequiredWorkflow represents the Workflow for the RequireWorkflowsRuleParameters object.
101
+ type RuleRequiredWorkflow struct {
102
+ Path string `json:"path"`
103
+ Ref * string `json:"ref,omitempty"`
104
+ RepositoryID * int64 `json:"repository_id,omitempty"`
105
+ Sha * string `json:"sha,omitempty"`
106
+ }
107
+
108
+ // RequiredWorkflowsRuleParameters represents the workflows rule parameters.
109
+ type RequiredWorkflowsRuleParameters struct {
110
+ RequiredWorkflows []* RuleRequiredWorkflow `json:"workflows"`
111
+ }
112
+
100
113
// RepositoryRule represents a GitHub Rule.
101
114
type RepositoryRule struct {
102
115
Type string `json:"type"`
@@ -171,6 +184,16 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error {
171
184
bytes , _ := json .Marshal (params )
172
185
rawParams := json .RawMessage (bytes )
173
186
187
+ r .Parameters = & rawParams
188
+ case "workflows" :
189
+ params := RequiredWorkflowsRuleParameters {}
190
+ if err := json .Unmarshal (* RepositoryRule .Parameters , & params ); err != nil {
191
+ return err
192
+ }
193
+
194
+ bytes , _ := json .Marshal (params )
195
+ rawParams := json .RawMessage (bytes )
196
+
174
197
r .Parameters = & rawParams
175
198
default :
176
199
r .Type = ""
@@ -329,6 +352,18 @@ func NewTagNamePatternRule(params *RulePatternParameters) (rule *RepositoryRule)
329
352
}
330
353
}
331
354
355
+ // NewRequiredWorkflowsRule creates a rule to require which status checks must pass before branches can be merged into a branch rule.
356
+ func NewRequiredWorkflowsRule (params * RequiredWorkflowsRuleParameters ) (rule * RepositoryRule ) {
357
+ bytes , _ := json .Marshal (params )
358
+
359
+ rawParams := json .RawMessage (bytes )
360
+
361
+ return & RepositoryRule {
362
+ Type : "workflows" ,
363
+ Parameters : & rawParams ,
364
+ }
365
+ }
366
+
332
367
// Ruleset represents a GitHub ruleset object.
333
368
type Ruleset struct {
334
369
ID * int64 `json:"id,omitempty"`
0 commit comments