11import FreeGen2 ._
22import scala .sys .process ._
3+ import org .typelevel .sbt .gha .{PermissionValue , Permissions }
34import org .typelevel .sbt .tpolecat .{DevMode , CiMode }
45
56// Library versions all in one place, for convenience and sanity.
@@ -28,6 +29,18 @@ lazy val scala212Version = "2.12.21"
2829lazy val scala213Version = " 2.13.18"
2930lazy val scala3Version = " 3.3.8"
3031lazy val allScalaVersions = List (scala212Version, scala213Version, scala3Version)
32+ lazy val doobieGitRemote =
33+ if (sys.env.get(" GITHUB_ACTIONS" ).contains(" true" ))
34+ sys.env
35+ .get(" GITHUB_TOKEN" )
36+ .filter(_.nonEmpty)
37+ .map(token => s " https://x-access-token: $token@github.com/typelevel/doobie.git " )
38+ .getOrElse(" https://github.com/typelevel/doobie.git" )
39+ else
40+ " git@github.com:typelevel/doobie.git"
41+ lazy val doobieGithubWorkflowPermissions =
42+ Permissions .Specify .defaultRestrictive
43+ .withContents(PermissionValue .Write )
3144// scala-steward:off
3245lazy val slf4jVersion = " 1.7.36"
3346// scala-steward:on
@@ -44,6 +57,8 @@ ThisBuild / developers += tlGitHubDev("tpolecat", "Rob Norris")
4457ThisBuild / tpolecatDefaultOptionsMode :=
4558 (if (sys.env.contains(" CI" )) CiMode else DevMode )
4659ThisBuild / githubWorkflowJavaVersions := Seq (JavaSpec .temurin(" 11" ))
60+ useReadableConsoleGit
61+ ThisBuild / githubWorkflowPermissions := Some (doobieGithubWorkflowPermissions)
4762ThisBuild / githubWorkflowBuildPreamble ++= Seq (
4863 WorkflowStep .Run (
4964 commands = List (" docker compose up -d" ),
@@ -86,6 +101,27 @@ ThisBuild / githubWorkflowJobSetup ~= { steps =>
86101 case s => s
87102 }
88103}
104+ ThisBuild / githubWorkflowPublishPostamble ++= Seq (
105+ WorkflowStep .Run (
106+ commands = List (" docker compose up -d" ),
107+ name = Some (" Start up Postgres for docs publish" ),
108+ cond = Some (" startsWith(github.ref, 'refs/tags/v')" )
109+ ),
110+ WorkflowStep .Run (
111+ commands = List (
112+ " git config --global user.name \" github-actions[bot]\" " ,
113+ " git config --global user.email \" 41898282+github-actions[bot]@users.noreply.github.com\" "
114+ ),
115+ name = Some (" Configure git for docs publish" ),
116+ cond = Some (" startsWith(github.ref, 'refs/tags/v')" )
117+ ),
118+ WorkflowStep .Sbt (
119+ commands = List (" docs/makeSite" , " docs/ghpagesPushSite" ),
120+ name = Some (" Publish Doc Site" ),
121+ cond = Some (" startsWith(github.ref, 'refs/tags/v')" ),
122+ env = Map (" SBT_GHPAGES_COMMIT_MESSAGE" -> " Update docs for ${{ github.ref_name }}" )
123+ )
124+ )
89125
90126ThisBuild / mergifyPrRules += MergifyPrRule (
91127 name = " merge-when-ci-pass" ,
@@ -576,7 +612,7 @@ lazy val docs = projectMatrix
576612
577613 // postgis is `provided` dependency for users, and section from book of doobie needs it
578614 libraryDependencies += postgisDep,
579- git.remoteRepo := " git@github.com:typelevel/doobie.git " ,
615+ git.remoteRepo := doobieGitRemote ,
580616 ghpagesNoJekyll := true ,
581617 publish / skip := true ,
582618 paradoxTheme := Some (builtinParadoxTheme(" generic" )),
0 commit comments