@@ -18,22 +18,190 @@ package org.typelevel.sbt.gha
1818
1919sealed trait WorkflowTrigger
2020object WorkflowTrigger {
21- // TODO: make bin compat friendly
22- // TODO: Make branches and tags work like Paths
23- case class PullRequest (
24- branches : List [String ] = List .empty,
25- paths : Paths = Paths .None ,
26- branchesIgnore : List [String ] = List .empty,
27- tags : List [String ] = List .empty,
28- tagsIgnore : List [String ] = List .empty,
29- types : List [PREventType ] = List .empty
30- ) extends WorkflowTrigger
31-
32- case class Push (
33- branches : List [String ] = List .empty,
34- branchesIgnore : List [String ] = List .empty,
35- paths : Paths = Paths .None ,
36- tags : List [String ] = List .empty,
37- tagsIgnore : List [String ] = List .empty
38- ) extends WorkflowTrigger
21+ sealed trait PullRequest extends WorkflowTrigger {
22+ def branches : List [String ]
23+ def paths : Paths
24+ def branchesIgnore : List [String ]
25+ def tags : List [String ]
26+ def tagsIgnore : List [String ]
27+ def types : List [PREventType ]
28+
29+ def withBranches (branches : List [String ]): PullRequest
30+ def withPaths (paths : Paths ): PullRequest
31+ def withBranchesIgnore (branchesIgnore : List [String ]): PullRequest
32+ def withTags (tags : List [String ]): PullRequest
33+ def withTagsIgnore (tagsIgnore : List [String ]): PullRequest
34+ def withTypes (types : List [PREventType ]): PullRequest
35+ }
36+ object PullRequest {
37+ def apply (
38+ branches : List [String ] = List .empty,
39+ paths : Paths = Paths .None ,
40+ branchesIgnore : List [String ] = List .empty,
41+ tags : List [String ] = List .empty,
42+ tagsIgnore : List [String ] = List .empty,
43+ types : List [PREventType ] = List .empty
44+ ): PullRequest = Impl (
45+ branches = branches,
46+ paths = paths,
47+ branchesIgnore = branchesIgnore,
48+ tags = tags,
49+ tagsIgnore = tagsIgnore,
50+ types = types
51+ )
52+
53+ private final case class Impl (
54+ branches : List [String ],
55+ paths : Paths ,
56+ branchesIgnore : List [String ],
57+ tags : List [String ],
58+ tagsIgnore : List [String ],
59+ types : List [PREventType ]
60+ ) extends PullRequest {
61+ override def productPrefix = " PullRequest"
62+
63+ // scalafmt: { maxColumn = 200 }
64+ def withBranches (branches : List [String ]): PullRequest = copy(branches = branches)
65+ def withPaths (paths : Paths ): PullRequest = copy(paths = paths)
66+ def withBranchesIgnore (branchesIgnore : List [String ]): PullRequest = copy(branchesIgnore = branchesIgnore)
67+ def withTags (tags : List [String ]): PullRequest = copy(tags = tags)
68+ def withTagsIgnore (tagsIgnore : List [String ]): PullRequest = copy(tagsIgnore = tagsIgnore)
69+ def withTypes (types : List [PREventType ]): PullRequest = copy(types = types)
70+ // scalafmt: { maxColumn = 96 }
71+ }
72+ }
73+
74+ sealed trait Push extends WorkflowTrigger {
75+ def branches : List [String ]
76+ def branchesIgnore : List [String ]
77+ def paths : Paths
78+ def tags : List [String ]
79+ def tagsIgnore : List [String ]
80+
81+ def withBranches (branches : List [String ]): Push
82+ def withBranchesIgnore (branchesIgnore : List [String ]): Push
83+ def withPaths (paths : Paths ): Push
84+ def withTags (tags : List [String ]): Push
85+ def withTagsIgnore (tagsIgnore : List [String ]): Push
86+ }
87+ object Push {
88+ def apply (
89+ branches : List [String ] = List .empty,
90+ branchesIgnore : List [String ] = List .empty,
91+ paths : Paths = Paths .None ,
92+ tags : List [String ] = List .empty,
93+ tagsIgnore : List [String ] = List .empty
94+ ): Push = Impl (
95+ branches = branches,
96+ branchesIgnore = branchesIgnore,
97+ paths = paths,
98+ tags = tags,
99+ tagsIgnore = tagsIgnore
100+ )
101+
102+ private final case class Impl (
103+ branches : List [String ],
104+ branchesIgnore : List [String ],
105+ paths : Paths ,
106+ tags : List [String ],
107+ tagsIgnore : List [String ]
108+ ) extends Push {
109+ override def productPrefix = " Push"
110+
111+ // scalafmt: { maxColumn = 200 }
112+ def withBranches (branches : List [String ]): Push = copy(branches = branches)
113+ def withBranchesIgnore (branchesIgnore : List [String ]): Push = copy(branchesIgnore = branchesIgnore)
114+ def withPaths (paths : Paths ): Push = copy(paths = paths)
115+ def withTags (tags : List [String ]): Push = copy(tags = tags)
116+ def withTagsIgnore (tagsIgnore : List [String ]): Push = copy(tagsIgnore = tagsIgnore)
117+ // scalafmt: { maxColumn = 96 }
118+ }
119+ }
120+
121+ sealed trait WorkflowCall extends WorkflowTrigger
122+ object WorkflowCall {
123+ def apply (): WorkflowCall = Impl
124+ private final case object Impl extends WorkflowCall {
125+ override def productPrefix = " WorkflowCall"
126+ }
127+ }
128+
129+ /**
130+ * A workflow trigger, inserted directly into the yaml, with 1 level of indention. This is an
131+ * escape hatch for people wanting triggers other than the supported ones.
132+ */
133+ sealed trait Raw extends WorkflowTrigger {
134+ def toYaml : String
135+ }
136+ object Raw {
137+ def raw (yaml : String ): Raw = Impl (yaml)
138+
139+ private final case class Impl (toYaml : String ) extends Raw
140+ }
141+
142+ /*
143+ * Other Triggers not implemented here:
144+ *
145+ * branch_protection_rule
146+ * check_run
147+ * check_suite
148+ * create
149+ * delete
150+ * deployment
151+ * deployment_status
152+ * discussion
153+ * discussion_comment
154+ * fork
155+ * gollum
156+ * issue_comment
157+ * issues
158+ * label
159+ * merge_group
160+ * milestone
161+ * page_build
162+ * public
163+ * pull_request_comment (use issue_comment)
164+ * pull_request_review
165+ * pull_request_review_comment
166+ * pull_request_target
167+ * registry_package
168+ * release
169+ * repository_dispatch
170+ * schedule
171+ * status
172+ * watch
173+ * workflow_disbranch_protection_rule
174+ * check_run
175+ * check_suite
176+ * create
177+ * delete
178+ * deployment
179+ * deployment_status
180+ * discussion
181+ * discussion_comment
182+ * fork
183+ * gollum
184+ * issue_comment
185+ * issues
186+ * label
187+ * merge_group
188+ * milestone
189+ * page_build
190+ * public
191+ * pull_request
192+ * pull_request_comment (use issue_comment)
193+ * pull_request_review
194+ * pull_request_review_comment
195+ * pull_request_target
196+ * push
197+ * registry_package
198+ * release
199+ * repository_dispatch
200+ * schedule
201+ * status
202+ * watch
203+ * workflow_dispatch
204+ * workflow_runpatch
205+ * workflow_run
206+ */
39207}
0 commit comments