Skip to content

Commit

Permalink
Update checkout action (#82)
Browse files Browse the repository at this point in the history
* update checkout action.

* update checkout action version.

* update checkout action.

* fix.
  • Loading branch information
khajavi authored Jan 6, 2023
1 parent 8b66caa commit 15b82bc
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 72 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
steps:
- name: Checkout current branch
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- name: Setup Scala and Java
Expand All @@ -40,7 +40,7 @@ jobs:
java: ['[email protected]', '[email protected]']
scala: ['2.12.17']
steps:
- uses: actions/checkout@v3.2.0
- uses: actions/checkout@v3.3.0
- uses: olafurpg/setup-scala@v13
with:
java-version: ${{ matrix.java }}
Expand All @@ -55,7 +55,7 @@ jobs:
needs: [build,lint]
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3.2.0
- uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v13
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3.3.0
with:
fetch-depth: '0'
- name: Setup Scala
Expand All @@ -37,7 +37,7 @@ jobs:
if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3.3.0
with:
fetch-depth: '0'
- name: Setup Scala
Expand All @@ -61,7 +61,7 @@ jobs:
if: ${{ github.event_name == 'push' }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3.3.0
with:
ref: ${{ github.head_ref }}
fetch-depth: '0'
Expand Down
140 changes: 74 additions & 66 deletions zio-sbt-website/src/main/scala/zio/sbt/WebsiteUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,68 @@ object WebsiteUtils {
docsPublishBranch: String,
sbtBuildOptions: List[String] = List.empty,
versioning: DocsVersioning = SemanticVersioning
): String =
): String = {
object Actions {
val checkout: ActionRef = ActionRef("actions/[email protected]")
val `setup-java`: ActionRef = ActionRef("actions/[email protected]")
val `setup-node`: ActionRef = ActionRef("actions/setup-node@v3")
}

import Actions.*

object Steps {
val Checkout: Step.SingleStep = Step.SingleStep(
name = "Git Checkout",
uses = Some(checkout),
parameters = Map("fetch-depth" -> "0".asJson)
)

val SetupJava: Step.SingleStep = Step.SingleStep(
name = "Setup Scala",
uses = Some(`setup-java`),
parameters = Map(
"distribution" -> "temurin".asJson,
"java-version" -> 17.asJson,
"check-latest" -> true.asJson
)
)

val SetupNodeJs: Step.SingleStep = Step.SingleStep(
name = "Setup NodeJs",
uses = Some(`setup-node`),
parameters = Map(
"node-version" -> "16.x".asJson,
"registry-url" -> "https://registry.npmjs.org".asJson
)
)

val GenerateReadme: Step.SingleStep = Step.SingleStep(
name = "Generate Readme",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/generateReadme")
)

val CheckWebsiteBuildProcess: Step.SingleStep = Step.SingleStep(
name = "Check website build process",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/buildWebsite")
)

val CheckGithubWorkflow: Step.SingleStep = Step.SingleStep(
name = "Check that site workflow is up to date",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/checkGithubWorkflow")
)

val PublishToNpmRegistry: Step.SingleStep =
Step.SingleStep(
name = "Publish Docs to NPM Registry",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/${versioning.npmCommand}"),
env = Map(
"NODE_AUTH_TOKEN" -> "${{ secrets.NPM_TOKEN }}"
)
)
}

import Steps.*

io.circe.yaml
.Printer(
preserveOrder = true,
Expand Down Expand Up @@ -201,28 +262,10 @@ object WebsiteUtils {
steps = Seq(
Step.StepSequence(
Seq(
Step.SingleStep(
name = "Git Checkout",
uses = Some(ActionRef("actions/[email protected]")),
parameters = Map("fetch-depth" -> "0".asJson)
),
Step.SingleStep(
name = "Setup Scala",
uses = Some(ActionRef("actions/[email protected]")),
parameters = Map(
"distribution" -> "temurin".asJson,
"java-version" -> 17.asJson,
"check-latest" -> true.asJson
)
),
Step.SingleStep(
name = "Check that site workflow is up to date",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/checkGithubWorkflow")
),
Step.SingleStep(
name = "Check website build process",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/buildWebsite")
)
Checkout,
SetupJava,
CheckGithubWorkflow,
CheckWebsiteBuildProcess
)
)
)
Expand All @@ -239,35 +282,10 @@ object WebsiteUtils {
steps = Seq(
Step.StepSequence(
Seq(
Step.SingleStep(
name = "Git Checkout",
uses = Some(ActionRef("actions/[email protected]")),
parameters = Map("fetch-depth" -> "0".asJson)
),
Step.SingleStep(
name = "Setup Scala",
uses = Some(ActionRef("actions/[email protected]")),
parameters = Map(
"distribution" -> "temurin".asJson,
"java-version" -> 17.asJson,
"check-latest" -> true.asJson
)
),
Step.SingleStep(
name = "Setup NodeJs",
uses = Some(ActionRef("actions/setup-node@v3")),
parameters = Map(
"node-version" -> "16.x".asJson,
"registry-url" -> "https://registry.npmjs.org".asJson
)
),
Step.SingleStep(
name = "Publish Docs to NPM Registry",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/${versioning.npmCommand}"),
env = Map(
"NODE_AUTH_TOKEN" -> "${{ secrets.NPM_TOKEN }}"
)
)
Checkout,
SetupJava,
SetupNodeJs,
PublishToNpmRegistry
)
)
)
Expand All @@ -279,25 +297,14 @@ object WebsiteUtils {
steps = Seq(
Step.SingleStep(
name = "Git Checkout",
uses = Some(ActionRef("actions/checkout@v3.2.0")),
uses = Some(checkout),
parameters = Map(
"ref" -> "${{ github.head_ref }}".asJson,
"fetch-depth" -> "0".asJson
)
),
Step.SingleStep(
name = "Setup Scala",
uses = Some(ActionRef("actions/[email protected]")),
parameters = Map(
"distribution" -> "temurin".asJson,
"java-version" -> 17.asJson,
"check-latest" -> true.asJson
)
),
Step.SingleStep(
name = "Generate Readme",
run = Some(s"sbt ${sbtBuildOptions.mkString(" ")} docs/generateReadme")
),
SetupJava,
GenerateReadme,
Step.SingleStep(
name = "Commit Changes",
run = Some("""|git config --local user.email "github-actions[bot]@users.noreply.github.com"
Expand Down Expand Up @@ -327,6 +334,7 @@ object WebsiteUtils {
)
).asJson
)
}

def releaseVersion(logger: String => Unit): Option[String] =
try "git tag --sort=committerdate".!!.split("\n").filter(_.startsWith("v")).lastOption.map(_.tail)
Expand Down

0 comments on commit 15b82bc

Please sign in to comment.