Skip to content

Commit a7b98af

Browse files
committed
Add permissions and concurrency. Refactor needs
1 parent 64bc77d commit a7b98af

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativePlugin.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ object GenerativePlugin extends AutoPlugin {
426426
if (job.needs.isEmpty)
427427
""
428428
else
429-
s"\nneeds: [${job.needs.mkString(", ")}]"
429+
job.needs.mkString("\nneeds: [", ", ", "]")
430430

431431
val renderedSecrets = job.secrets.fold("")(compileSecrets)
432432

@@ -460,7 +460,7 @@ object GenerativePlugin extends AutoPlugin {
460460
if (job.needs.isEmpty)
461461
""
462462
else
463-
s"\nneeds: [${job.needs.mkString(", ")}]"
463+
job.needs.mkString("\nneeds: [", ", ", "]")
464464

465465
val renderedEnvironment =
466466
job.environment.map(compileEnvironment).map("\n" + _).getOrElse("")

github-actions/src/main/scala/org/typelevel/sbt/gha/WorkflowJob.scala

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ sealed abstract class WorkflowJob extends Product with Serializable {
2121
def name: String
2222
def needs: List[String]
2323
def outputs: Map[String, String]
24+
def permissions: Option[Permissions]
25+
def concurrency: Option[Concurrency]
2426
// TODO: Check for other common properites, like `cond` and `need`
2527

2628
def withId(id: String): WorkflowJob
2729
def withName(name: String): WorkflowJob
2830
def withNeeds(needs: List[String]): WorkflowJob
2931
def withOutputs(outputs: Map[String, String]): WorkflowJob
32+
def withPermissions(permissions: Option[Permissions]): WorkflowJob
33+
def withConcurrency(concurrency: Option[Concurrency]): WorkflowJob
3034

3135
def updatedOutputs(name: String, value: String): WorkflowJob
3236
def concatOutputs(outputs: TraversableOnce[(String, String)]): WorkflowJob
@@ -245,6 +249,8 @@ object WorkflowJob {
245249
def secrets: Option[Secrets]
246250
def params: Map[String, String]
247251
def outputs: Map[String, String]
252+
def permissions: Option[Permissions]
253+
def concurrency: Option[Concurrency]
248254

249255
def withId(id: String): Use
250256
def withName(name: String): Use
@@ -253,6 +259,8 @@ object WorkflowJob {
253259
def withSecrets(secrets: Option[Secrets]): Use
254260
def withParams(params: Map[String, String]): Use
255261
def withOutputs(outputs: Map[String, String]): Use
262+
def withPermissions(permissions: Option[Permissions]): Use
263+
def withConcurrency(concurrency: Option[Concurrency]): Use
256264

257265
def updatedParams(name: String, value: String): Use
258266
def concatParams(params: TraversableOnce[(String, String)]): Use
@@ -267,15 +275,19 @@ object WorkflowJob {
267275
needs: List[String] = List.empty,
268276
secrets: Option[Secrets] = None,
269277
params: Map[String, String] = Map.empty,
270-
outputs: Map[String, String] = Map.empty
278+
outputs: Map[String, String] = Map.empty,
279+
permissions: Option[Permissions] = None,
280+
concurrency: Option[Concurrency] = None
271281
): Use = new Impl(
272282
id = id,
273283
name = name,
274284
uses = uses,
275285
needs = needs,
276286
secrets = secrets,
277287
params = params,
278-
outputs = outputs
288+
outputs = outputs,
289+
permissions = permissions,
290+
concurrency = concurrency
279291
)
280292
private final case class Impl(
281293
id: String,
@@ -284,15 +296,23 @@ object WorkflowJob {
284296
needs: List[String],
285297
secrets: Option[Secrets],
286298
params: Map[String, String],
287-
outputs: Map[String, String]
299+
outputs: Map[String, String],
300+
permissions: Option[Permissions],
301+
concurrency: Option[Concurrency]
288302
) extends Use {
303+
override def productPrefix = "Use"
304+
305+
// scalafmt: { maxColumn = 200 }
289306
override def withId(id: String): Use = copy(id = id)
290307
override def withName(name: String): Use = copy(name = name)
291308
override def withNeeds(needs: List[String]): Use = copy(needs = needs)
292309
override def withUses(uses: String): Use = copy(uses = uses)
293310
override def withSecrets(secrets: Option[Secrets]): Use = copy(secrets = secrets)
294311
override def withParams(params: Map[String, String]): Use = copy(params = params)
295312
override def withOutputs(outputs: Map[String, String]): Use = copy(outputs = outputs)
313+
override def withPermissions(permissions: Option[Permissions]): Use = copy(permissions = permissions)
314+
override def withConcurrency(concurrency: Option[Concurrency]): Use = copy(concurrency = concurrency)
315+
// scalafmt: { maxColumn = 96 }
296316

297317
override def updatedParams(name: String, value: String) =
298318
copy(params = params.updated(name, value))

0 commit comments

Comments
 (0)