gh_workflow/
event.rs

1#![allow(clippy::needless_update)]
2
3use std::collections::HashMap;
4
5use derive_setters::Setters;
6use merge::Merge;
7use serde::{Deserialize, Serialize};
8
9use crate::is_default;
10
11/// Represents all possible webhook events that can trigger a workflow
12/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
13#[derive(Default, Debug, Clone, Deserialize, Serialize, Merge, Setters, PartialEq, Eq)]
14#[setters(strip_option, into)]
15pub struct Event {
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub branch_protection_rule: Option<BranchProtectionRule>,
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub check_run: Option<CheckRun>,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub check_suite: Option<CheckSuite>,
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub create: Option<Create>,
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub delete: Option<Delete>,
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub deployment: Option<Deployment>,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub deployment_status: Option<DeploymentStatus>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub discussion: Option<Discussion>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub discussion_comment: Option<DiscussionComment>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub fork: Option<bool>,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub gollum: Option<bool>,
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub issue_comment: Option<IssueComment>,
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub issues: Option<Issues>,
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub label: Option<Label>,
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub merge_group: Option<MergeGroup>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub milestone: Option<Milestone>,
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub page_build: Option<bool>,
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub public: Option<bool>,
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub pull_request: Option<PullRequest>,
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub pull_request_review: Option<PullRequestReview>,
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub pull_request_review_comment: Option<PullRequestReviewComment>,
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub pull_request_target: Option<PullRequestTarget>,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub push: Option<Push>,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub registry_package: Option<RegistryPackage>,
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub release: Option<Release>,
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub repository_dispatch: Option<RepositoryDispatch>,
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub schedule: Option<Schedule>,
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub status: Option<bool>,
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub watch: Option<Watch>,
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub workflow_call: Option<WorkflowCall>,
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub workflow_dispatch: Option<WorkflowDispatch>,
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub workflow_run: Option<WorkflowRun>,
80}
81
82/// Types of branch protection rule events
83/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#branch_protection_rule
84#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
85#[serde(rename_all = "snake_case")]
86pub enum BranchProtectionRuleType {
87    /// A branch protection rule was created
88    Created,
89    /// A branch protection rule was edited
90    Edited,
91    /// A branch protection rule was deleted
92    Deleted,
93}
94
95/// Configuration for branch protection rule events
96#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
97#[setters(strip_option, into)]
98pub struct BranchProtectionRule {
99    #[serde(default, skip_serializing_if = "Vec::is_empty")]
100    pub types: Vec<BranchProtectionRuleType>,
101}
102
103impl BranchProtectionRule {
104    /// Adds a branch protection rule event type to filter on
105    pub fn add_type(mut self, type_: BranchProtectionRuleType) -> Self {
106        self.types.push(type_);
107        self
108    }
109}
110
111/// Types of check run events
112/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#check_run
113#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
114#[serde(rename_all = "snake_case")]
115pub enum CheckRunType {
116    /// A check run was created
117    Created,
118    /// A check run was requested to be re-run
119    Rerequested,
120    /// A check run was completed
121    Completed,
122    /// A user requested an action from the check run
123    RequestedAction,
124}
125
126#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
127#[setters(strip_option, into)]
128pub struct CheckRun {
129    #[serde(default, skip_serializing_if = "Vec::is_empty")]
130    pub types: Vec<CheckRunType>,
131}
132
133impl CheckRun {
134    /// Adds a check run event type to filter on
135    pub fn add_type(mut self, type_: CheckRunType) -> Self {
136        self.types.push(type_);
137        self
138    }
139}
140
141/// Types of check suite events
142/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#check_suite
143#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
144#[serde(rename_all = "snake_case")]
145pub enum CheckSuiteType {
146    /// A check suite has completed
147    Completed,
148}
149
150/// Configuration for check suite events
151
152#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
153#[setters(strip_option, into)]
154pub struct CheckSuite {
155    #[serde(default, skip_serializing_if = "Vec::is_empty")]
156    pub types: Vec<CheckSuiteType>,
157}
158
159impl CheckSuite {
160    /// Adds a check suite event type to filter on
161    pub fn add_type(mut self, type_: CheckSuiteType) -> Self {
162        self.types.push(type_);
163        self
164    }
165}
166
167/// Configuration for create events (branch or tag creation)
168/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#create
169#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
170#[setters(strip_option, into)]
171pub struct Create {
172    /// Filter on specific branch names
173    #[serde(default, skip_serializing_if = "Vec::is_empty")]
174    pub branches: Vec<String>,
175    /// Filter on specific tag names
176    #[serde(default, skip_serializing_if = "Vec::is_empty")]
177    pub tags: Vec<String>,
178}
179
180impl Create {
181    /// Adds a branch name to filter on
182    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
183        self.branches.push(branch.into());
184        self
185    }
186
187    /// Adds a tag name to filter on
188    pub fn add_tag<S: Into<String>>(mut self, tag: S) -> Self {
189        self.tags.push(tag.into());
190        self
191    }
192}
193
194/// Configuration for delete events (branch or tag deletion)
195/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete
196#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
197#[setters(strip_option, into)]
198pub struct Delete {
199    /// Filter on specific branch names
200    #[serde(default, skip_serializing_if = "Vec::is_empty")]
201    pub branches: Vec<String>,
202    /// Filter on specific tag names
203    #[serde(default, skip_serializing_if = "Vec::is_empty")]
204    pub tags: Vec<String>,
205}
206
207impl Delete {
208    /// Adds a branch name to filter on
209    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
210        self.branches.push(branch.into());
211        self
212    }
213
214    /// Adds a tag name to filter on
215    pub fn add_tag<S: Into<String>>(mut self, tag: S) -> Self {
216        self.tags.push(tag.into());
217        self
218    }
219}
220
221/// Types of deployment events
222/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment
223
224#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
225#[setters(strip_option, into)]
226pub struct Deployment {
227    /// Filter on specific branch names
228    #[serde(default, skip_serializing_if = "Vec::is_empty")]
229    pub branches: Vec<String>,
230}
231
232impl Deployment {
233    /// Adds a branch name to filter on
234    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
235        self.branches.push(branch.into());
236        self
237    }
238}
239
240/// Types of deployment status events
241/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment_status
242
243#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
244#[setters(strip_option, into)]
245pub struct DeploymentStatus {
246    /// Filter on specific deployment states
247    #[serde(default, skip_serializing_if = "Vec::is_empty")]
248    pub states: Vec<String>,
249}
250
251impl DeploymentStatus {
252    /// Adds a deployment state to filter on
253    pub fn add_state<S: Into<String>>(mut self, state: S) -> Self {
254        self.states.push(state.into());
255        self
256    }
257}
258
259/// Types of discussion events
260/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#discussion
261#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
262#[serde(rename_all = "snake_case")]
263pub enum DiscussionType {
264    /// A discussion was created
265    Created,
266    /// A discussion was edited
267    Edited,
268    /// A discussion was deleted
269    Deleted,
270    /// A discussion was transferred between repositories
271    Transferred,
272    /// A discussion was pinned
273    Pinned,
274    /// A discussion was unpinned
275    Unpinned,
276    /// A discussion was labeled
277    Labeled,
278    /// A discussion was unlabeled
279    Unlabeled,
280    /// A discussion was locked
281    Locked,
282    /// A discussion was unlocked
283    Unlocked,
284    /// A discussion's category was changed
285    CategoryChanged,
286    /// A discussion was marked as answered
287    Answered,
288    /// A discussion was unmarked as answered
289    Unanswered,
290}
291
292/// Configuration for discussion events
293
294#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
295pub struct Discussion {
296    /// Filter on specific discussion event types
297    #[serde(default, skip_serializing_if = "Vec::is_empty")]
298    pub types: Vec<DiscussionType>,
299}
300
301impl Discussion {
302    /// Adds a discussion event type to filter on
303    pub fn add_type(mut self, type_: DiscussionType) -> Self {
304        self.types.push(type_);
305        self
306    }
307}
308
309/// Types of discussion comment events
310/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#discussion_comment
311#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
312#[serde(rename_all = "snake_case")]
313pub enum DiscussionCommentType {
314    /// A discussion comment was created
315    Created,
316    /// A discussion comment was edited
317    Edited,
318    /// A discussion comment was deleted
319    Deleted,
320}
321
322/// Configuration for discussion comment events
323
324#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
325pub struct DiscussionComment {
326    /// Filter on specific discussion comment event types
327    #[serde(default, skip_serializing_if = "Vec::is_empty")]
328    pub types: Vec<DiscussionCommentType>,
329}
330
331impl DiscussionComment {
332    /// Adds a discussion comment event type to filter on
333    pub fn add_type(mut self, type_: DiscussionCommentType) -> Self {
334        self.types.push(type_);
335        self
336    }
337}
338
339/// Configuration for issue comment events
340/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment
341#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
342pub struct IssueComment {
343    /// Filter on specific issue comment event types
344    #[serde(default, skip_serializing_if = "Vec::is_empty")]
345    pub types: Vec<IssueCommentType>,
346}
347
348/// Types of issue comment events
349#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
350#[serde(rename_all = "snake_case")]
351pub enum IssueCommentType {
352    /// An issue comment was created
353    Created,
354    /// An issue comment was edited
355    Edited,
356    /// An issue comment was deleted
357    Deleted,
358}
359
360impl IssueComment {
361    /// Adds an issue comment event type to filter on
362    pub fn add_type(mut self, type_: IssueCommentType) -> Self {
363        self.types.push(type_);
364        self
365    }
366}
367
368/// Types of issue events
369/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues
370#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
371#[serde(rename_all = "snake_case")]
372pub enum IssuesType {
373    /// An issue was opened
374    Opened,
375    /// An issue was edited
376    Edited,
377    /// An issue was deleted
378    Deleted,
379    /// An issue was transferred between repositories
380    Transferred,
381    /// An issue was pinned
382    Pinned,
383    /// An issue was unpinned
384    Unpinned,
385    /// An issue was closed
386    Closed,
387    /// A closed issue was reopened
388    Reopened,
389    /// An issue was assigned to a user
390    Assigned,
391    /// An issue was unassigned from a user
392    Unassigned,
393    /// A label was added to an issue
394    Labeled,
395    /// A label was removed from an issue
396    Unlabeled,
397    /// An issue was locked
398    Locked,
399    /// An issue was unlocked
400    Unlocked,
401    /// An issue was added to a milestone
402    Milestoned,
403    /// An issue was removed from a milestone
404    Demilestoned,
405}
406
407/// Configuration for issue events
408
409#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
410#[setters(strip_option, into)]
411pub struct Issues {
412    /// Filter on specific issue event types
413    #[serde(default, skip_serializing_if = "Vec::is_empty")]
414    pub types: Vec<IssuesType>,
415}
416
417impl Issues {
418    /// Adds an issue event type to filter on
419    pub fn add_type(mut self, type_: IssuesType) -> Self {
420        self.types.push(type_);
421        self
422    }
423}
424
425/// Types of label events
426/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#label
427#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
428#[serde(rename_all = "snake_case")]
429pub enum LabelType {
430    /// A label was created
431    Created,
432    /// A label was edited
433    Edited,
434    /// A label was deleted
435    Deleted,
436}
437
438/// Configuration for label events
439
440#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
441#[setters(strip_option, into)]
442pub struct Label {
443    /// Filter on specific label event types
444    #[serde(default, skip_serializing_if = "Vec::is_empty")]
445    pub types: Vec<LabelType>,
446}
447
448impl Label {
449    /// Adds a label event type to filter on
450    pub fn add_type(mut self, type_: LabelType) -> Self {
451        self.types.push(type_);
452        self
453    }
454}
455
456#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
457#[serde(rename_all = "snake_case")]
458pub enum MergeGroupType {
459    ChecksRequested,
460}
461
462#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
463#[setters(strip_option, into)]
464pub struct MergeGroup {
465    #[serde(default, skip_serializing_if = "Vec::is_empty")]
466    pub types: Vec<MergeGroupType>,
467}
468
469impl MergeGroup {
470    pub fn add_type(mut self, type_: MergeGroupType) -> Self {
471        self.types.push(type_);
472        self
473    }
474}
475
476#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
477#[serde(rename_all = "snake_case")]
478pub enum MilestoneType {
479    Created,
480    Closed,
481    Opened,
482    Edited,
483    Deleted,
484}
485
486#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
487#[setters(strip_option, into)]
488pub struct Milestone {
489    #[serde(default, skip_serializing_if = "Vec::is_empty")]
490    pub types: Vec<MilestoneType>,
491}
492
493impl Milestone {
494    pub fn add_type(mut self, type_: MilestoneType) -> Self {
495        self.types.push(type_);
496        self
497    }
498}
499
500#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
501#[serde(rename_all = "snake_case")]
502pub enum PullRequestType {
503    Assigned,
504    Unassigned,
505    Labeled,
506    Unlabeled,
507    Opened,
508    Edited,
509    Closed,
510    Reopened,
511    Synchronize,
512    ReadyForReview,
513    Locked,
514    Unlocked,
515    ReviewRequested,
516    ReviewRequestRemoved,
517}
518
519#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
520#[setters(strip_option, into)]
521pub struct PullRequest {
522    #[serde(default, skip_serializing_if = "Vec::is_empty")]
523    pub types: Vec<PullRequestType>,
524    #[serde(default, skip_serializing_if = "Vec::is_empty")]
525    pub branches: Vec<String>,
526    #[serde(default, skip_serializing_if = "Vec::is_empty")]
527    pub paths: Vec<String>,
528}
529
530impl PullRequest {
531    pub fn add_type(mut self, type_: PullRequestType) -> Self {
532        self.types.push(type_);
533        self
534    }
535
536    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
537        self.branches.push(branch.into());
538        self
539    }
540
541    pub fn add_path<S: Into<String>>(mut self, path: S) -> Self {
542        self.paths.push(path.into());
543        self
544    }
545}
546
547/// Types of pull request review events
548/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review
549#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
550#[serde(rename_all = "snake_case")]
551pub enum PullRequestReviewType {
552    /// A review was submitted for a pull request
553    Submitted,
554    /// A review was edited
555    Edited,
556    /// A review was dismissed
557    Dismissed,
558}
559
560/// Configuration for pull request review events
561
562#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
563#[setters(strip_option, into)]
564pub struct PullRequestReview {
565    /// Filter on specific pull request review event types
566    #[serde(default, skip_serializing_if = "Vec::is_empty")]
567    pub types: Vec<PullRequestReviewType>,
568}
569
570impl PullRequestReview {
571    /// Adds a pull request review event type to filter on
572    pub fn add_type(mut self, type_: PullRequestReviewType) -> Self {
573        self.types.push(type_);
574        self
575    }
576}
577
578/// Types of pull request review comment events
579/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment
580#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
581#[serde(rename_all = "snake_case")]
582pub enum PullRequestReviewCommentType {
583    /// A review comment was created
584    Created,
585    /// A review comment was edited
586    Edited,
587    /// A review comment was deleted
588    Deleted,
589}
590
591/// Configuration for pull request review comment events
592#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
593#[setters(strip_option, into)]
594pub struct PullRequestReviewComment {
595    /// Filter on specific pull request review comment event types
596    #[serde(default, skip_serializing_if = "Vec::is_empty")]
597    pub types: Vec<PullRequestReviewCommentType>,
598}
599
600impl PullRequestReviewComment {
601    /// Adds a pull request review comment event type to filter on
602    pub fn add_type(mut self, type_: PullRequestReviewCommentType) -> Self {
603        self.types.push(type_);
604        self
605    }
606}
607
608/// Configuration for pull request target events
609/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
610#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
611#[setters(strip_option, into)]
612pub struct PullRequestTarget {
613    /// Filter on specific pull request event types
614    #[serde(default, skip_serializing_if = "Vec::is_empty")]
615    pub types: Vec<PullRequestType>,
616    /// Filter on specific branch names
617    #[serde(default, skip_serializing_if = "Vec::is_empty")]
618    pub branches: Vec<String>,
619}
620
621impl PullRequestTarget {
622    /// Adds a pull request event type to filter on
623    pub fn add_type(mut self, type_: PullRequestType) -> Self {
624        self.types.push(type_);
625        self
626    }
627
628    /// Adds a branch name to filter on
629    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
630        self.branches.push(branch.into());
631        self
632    }
633}
634
635/// Configuration for push events
636/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
637#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
638#[setters(strip_option, into)]
639pub struct Push {
640    /// Filter on specific branch names
641    #[serde(default, skip_serializing_if = "Vec::is_empty")]
642    pub branches: Vec<String>,
643    /// Filter on specific file paths
644    #[serde(default, skip_serializing_if = "Vec::is_empty")]
645    pub paths: Vec<String>,
646    /// Filter on specific tags
647    #[serde(default, skip_serializing_if = "Vec::is_empty")]
648    pub tags: Vec<String>,
649}
650
651impl Push {
652    /// Adds a branch name to filter on
653    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
654        self.branches.push(branch.into());
655        self
656    }
657
658    /// Adds a file path to filter on
659    pub fn add_path<S: Into<String>>(mut self, path: S) -> Self {
660        self.paths.push(path.into());
661        self
662    }
663
664    /// Adds a tag name to filter on
665    pub fn add_tag<S: Into<String>>(mut self, tag: S) -> Self {
666        self.tags.push(tag.into());
667        self
668    }
669}
670
671/// Types of registry package events
672/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package
673#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
674#[serde(rename_all = "snake_case")]
675pub enum RegistryPackageType {
676    /// A package was published
677    Published,
678    /// A package was updated
679    Updated,
680}
681
682/// Configuration for registry package events
683
684#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
685#[setters(strip_option, into)]
686pub struct RegistryPackage {
687    /// Filter on specific registry package event types
688    #[serde(default, skip_serializing_if = "Vec::is_empty")]
689    pub types: Vec<RegistryPackageType>,
690}
691
692impl RegistryPackage {
693    /// Adds a registry package event type to filter on
694    pub fn add_type(mut self, type_: RegistryPackageType) -> Self {
695        self.types.push(type_);
696        self
697    }
698}
699
700/// Types of release events
701/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
702#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
703#[serde(rename_all = "snake_case")]
704pub enum ReleaseType {
705    /// A release was published
706    Published,
707    /// A release was unpublished
708    Unpublished,
709    /// A release was created
710    Created,
711    /// A release was edited
712    Edited,
713    /// A release was deleted
714    Deleted,
715    /// A release was marked as a pre-release
716    Prereleased,
717    /// A release was released
718    Released,
719}
720
721/// Configuration for release events
722
723#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
724#[setters(strip_option, into)]
725pub struct Release {
726    /// Filter on specific release event types
727    #[serde(default, skip_serializing_if = "Vec::is_empty")]
728    pub types: Vec<ReleaseType>,
729}
730
731impl Release {
732    /// Adds a release event type to filter on
733    pub fn add_type(mut self, type_: ReleaseType) -> Self {
734        self.types.push(type_);
735        self
736    }
737}
738
739#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
740#[setters(strip_option, into)]
741pub struct RepositoryDispatch {
742    #[serde(default, skip_serializing_if = "Vec::is_empty")]
743    pub types: Vec<String>,
744}
745
746impl RepositoryDispatch {
747    pub fn add_type<S: Into<String>>(mut self, type_: S) -> Self {
748        self.types.push(type_.into());
749        self
750    }
751}
752
753#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
754#[setters(strip_option, into)]
755pub struct Schedule {
756    #[serde(default, skip_serializing_if = "Vec::is_empty")]
757    pub cron: Vec<String>,
758}
759
760impl Schedule {
761    pub fn add_cron<S: Into<String>>(mut self, cron: S) -> Self {
762        self.cron.push(cron.into());
763        self
764    }
765}
766
767#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
768#[setters(strip_option, into)]
769pub struct Watch {
770    #[serde(default, skip_serializing_if = "Vec::is_empty")]
771    pub types: Vec<String>,
772}
773
774impl Watch {
775    pub fn add_type<S: Into<String>>(mut self, type_: S) -> Self {
776        self.types.push(type_.into());
777        self
778    }
779}
780
781/// Configuration for workflow call events
782/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_call
783#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
784#[setters(strip_option, into)]
785pub struct WorkflowCall {
786    /// Inputs for the workflow call
787    #[serde(skip_serializing_if = "HashMap::is_empty")]
788    pub inputs: HashMap<String, WorkflowCallInput>,
789    /// Outputs from the workflow call
790    #[serde(skip_serializing_if = "HashMap::is_empty")]
791    pub outputs: HashMap<String, WorkflowCallOutput>,
792    /// Secrets for the workflow call
793    #[serde(skip_serializing_if = "HashMap::is_empty")]
794    pub secrets: HashMap<String, WorkflowCallSecret>,
795}
796
797/// Configuration for workflow call input
798#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Setters, Eq)]
799#[setters(strip_option, into)]
800pub struct WorkflowCallInput {
801    /// Description of the input
802    #[serde(skip_serializing_if = "String::is_empty")]
803    pub description: String,
804    /// Indicates if the input is required
805    #[serde(skip_serializing_if = "is_default")]
806    pub required: bool,
807    /// Type of the input
808    #[serde(rename = "type")]
809    pub input_type: String,
810    /// Default value for the input
811    #[serde(skip_serializing_if = "Option::is_none")]
812    pub default: Option<String>,
813}
814
815/// Configuration for workflow call output
816#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Setters, Eq)]
817#[setters(strip_option, into)]
818pub struct WorkflowCallOutput {
819    /// Description of the output
820    #[serde(skip_serializing_if = "String::is_empty")]
821    pub description: String,
822    /// Value of the output
823    #[serde(skip_serializing_if = "String::is_empty")]
824    pub value: String,
825}
826
827/// Configuration for workflow call secret
828#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Setters, Eq)]
829#[setters(strip_option, into)]
830pub struct WorkflowCallSecret {
831    /// Description of the secret
832    #[serde(skip_serializing_if = "String::is_empty")]
833    pub description: String,
834    /// Indicates if the secret is required
835    #[serde(skip_serializing_if = "is_default")]
836    pub required: bool,
837}
838
839/// Configuration for workflow dispatch events
840/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
841
842#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
843#[setters(strip_option, into)]
844pub struct WorkflowDispatch {
845    /// Inputs for the workflow dispatch
846    #[serde(skip_serializing_if = "HashMap::is_empty")]
847    pub inputs: HashMap<String, WorkflowDispatchInput>,
848}
849
850/// Configuration for workflow dispatch input
851#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
852#[setters(strip_option, into)]
853pub struct WorkflowDispatchInput {
854    /// Description of the input
855    #[serde(skip_serializing_if = "String::is_empty")]
856    pub description: String,
857    /// Indicates if the input is required
858    #[serde(skip_serializing_if = "is_default")]
859    pub required: bool,
860    /// Type of the input
861    #[serde(rename = "type")]
862    pub input_type: String,
863    /// Default value for the input
864    #[serde(skip_serializing_if = "Option::is_none")]
865    pub default: Option<String>,
866}
867
868/// Types of workflow run events
869/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
870#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
871#[serde(rename_all = "snake_case")]
872pub enum WorkflowRunType {
873    /// A workflow run was completed
874    Completed,
875    /// A workflow run was requested
876    Requested,
877    /// A workflow run is in progress
878    InProgress,
879}
880
881/// Configuration for workflow run events
882#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
883#[setters(strip_option, into)]
884pub struct WorkflowRun {
885    /// Filter on specific workflow run event types
886    #[serde(default, skip_serializing_if = "Vec::is_empty")]
887    pub types: Vec<WorkflowRunType>,
888    /// Filter on specific workflow names
889    #[serde(default, skip_serializing_if = "Vec::is_empty")]
890    pub workflows: Vec<String>,
891    /// Filter on specific branch names
892    #[serde(default, skip_serializing_if = "Vec::is_empty")]
893    pub branches: Vec<String>,
894}
895
896impl WorkflowRun {
897    /// Adds a workflow run event type to filter on
898    pub fn add_type(mut self, type_: WorkflowRunType) -> Self {
899        self.types.push(type_);
900        self
901    }
902
903    /// Adds a workflow name to filter on
904    pub fn add_workflow<S: Into<String>>(mut self, workflow: S) -> Self {
905        self.workflows.push(workflow.into());
906        self
907    }
908
909    /// Adds a branch name to filter on
910    pub fn add_branch<S: Into<String>>(mut self, branch: S) -> Self {
911        self.branches.push(branch.into());
912        self
913    }
914}