Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make workflow dir configurable #166

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ ThisBuild / githubWorkflowPublish := Seq(

### General

- `githubWorkflowDir` : `File` - Where to place the workflow directory which contains the generated ci.yml and clean.yml files. (default: `baseDirectory.value / ".github"`)
- `githubIsWorkflowBuild` : `Boolean` – Indicates whether or not the build is currently running within a GitHub Actions Workflow
- `githubWorkflowName` : `String` – The name of the currently-running workflow. Will be undefined if not running in GitHub Actions.
- `githubWorkflowDefinition` : `Map[String, Any]` – The raw (parsed) contents of the workflow YAML definition. Will be undefined if not running in GitHub Actions, or if (for some reason) the workflow could not be identified. Workflows are located by taking the `githubWorkflowName` and finding the YAML definition which has the corresponding `name:` key/value pair.
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/sbtghactions/GenerativeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ trait GenerativeKeys {
lazy val githubWorkflowGenerate = taskKey[Unit]("Generates (and overwrites if extant) a ci.yml and clean.yml actions description according to configuration")
lazy val githubWorkflowCheck = taskKey[Unit]("Checks to see if the ci.yml and clean.yml files are equivalent to what would be generated and errors if otherwise")

lazy val githubWorkflowDir = settingKey[File]("Where to place the workflow directory which contains the generated ci.yml and clean.yml files. (default: baseDirectory.value / \".github\")")
lazy val githubWorkflowGeneratedCI = settingKey[Seq[WorkflowJob]]("The sequence of jobs which will make up the generated ci workflow (ci.yml)")
lazy val githubWorkflowGeneratedUploadSteps = settingKey[Seq[WorkflowStep]]("The sequence of steps used to upload intermediate build artifacts for an adjacent job")
lazy val githubWorkflowGeneratedDownloadSteps = settingKey[Seq[WorkflowStep]]("The sequence of steps used to download intermediate build artifacts published by an adjacent job")
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/sbtghactions/GenerativePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
}

private val workflowsDirTask = Def task {
val githubDir = baseDirectory.value / ".github"
val githubDir = githubWorkflowDir.value
val workflowsDir = githubDir / "workflows"

if (!githubDir.exists()) {
Expand Down Expand Up @@ -867,7 +867,8 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}

if (includeClean)
compare(cleanYml, expectedCleanContents)
})
},
githubWorkflowDir := baseDirectory.value / ".github")

private[sbtghactions] def diff(expected: String, actual: String): String = {
val expectedLines = expected.split("\n", -1)
Expand Down