sbt-typelevel icon indicating copy to clipboard operation
sbt-typelevel copied to clipboard

sbt-typelevel-github-actions: JobEnvironment prevents templating url

Open kubukoz opened this issue 10 months ago • 1 comments

Currently, JobEnvironment requires a java.net.URL, which seems to prevent certain usecases such as templating based on a step output - e.g. as in https://docs.github.com/en/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages.

I think a variant should be added that allows passing an arbitrary string that doesn't get parsed as a URL.

kubukoz avatar Feb 23 '25 21:02 kubukoz

According to me modify JobEnvironment to accept both URL and String values.

Steps to Fix: Introduce an alternative constructor that takes a raw string instead of a java.net.URL. Modify internal handling to support both URL validation (when needed) and raw string inputs. Ensure backward compatibility with existing code that already uses URL.

import java.net.URL

sealed trait JobEnvironment { def value: String }

final case class UrlEnvironment(url: URL) extends JobEnvironment { override def value: String = url.toString }

final case class StringEnvironment(rawValue: String) extends JobEnvironment { override def value: String = rawValue }

object JobEnvironment { def fromURL(url: URL): JobEnvironment = UrlEnvironment(url) def fromString(value: String): JobEnvironment = StringEnvironment(value) }

Supriya-57 avatar Mar 05 '25 08:03 Supriya-57