diff --git a/action.yml b/action.yml index 20a78ac..d59abfa 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,11 @@ inputs: description: Version of the sbt plugin to use. required: false default: '2.1.2' +outputs: + submission-id: + description: The ID of the submission created by the action + submission-api-url: + description: The URL of the submission created by the action runs: using: 'node16' main: 'dist/index.js' diff --git a/sbt-plugin/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala b/sbt-plugin/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala index 8c38d1d..9f921f7 100644 --- a/sbt-plugin/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala +++ b/sbt-plugin/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala @@ -96,12 +96,23 @@ object SubmitDependencyGraph { snapshot <- getSnapshot(httpResp) } yield { state.log.info(s"Submitted successfully as $snapshotUrl/${snapshot.id}") + setGithubOutputs( + "submission-id" -> snapshot.id.toString, + "submission-api-url" -> s"${snapshotUrl}/${snapshot.id}" + ) state } result.get } + // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter + private def setGithubOutputs(outputs: (String, String)*): Unit = IO.writeLines( + file(githubOutput), + outputs.toSeq.map { case (name, value) => s"${name}=${value}" }, + append = true + ) + private def getSnapshot(httpResp: FullResponse): Try[SnapshotResponse] = httpResp.status match { case status if status / 100 == 2 => @@ -168,6 +179,7 @@ object SubmitDependencyGraph { private def githubApiUrl(): String = githubCIEnv("GITHUB_API_URL") private def githubRepository(): String = githubCIEnv("GITHUB_REPOSITORY") private def githubToken(): String = githubCIEnv("GITHUB_TOKEN") + private def githubOutput(): String = githubCIEnv("GITHUB_OUTPUT") private def githubCIEnv(name: String): String = Properties.envOrNone(name).getOrElse {