Skip to content

Commit

Permalink
attempt to fix github pages deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
rolang committed Jul 13, 2024
1 parent ea086f7 commit c3f2c69
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,14 @@ jobs:
name: Deploy website
runs-on: ubuntu-latest
continue-on-error: false
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs:
- release
- build
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
53 changes: 39 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,21 @@ inThisBuild(
),
// this overrides the default post release jobs generated by zio-sbt-ci which publish the docs to NPM Registry
// can try to make it work with NPM later
ciPostReleaseJobs := Seq(
Job(
id = "deploy-website",
name = "Deploy website",
need = Seq("release"),
runsOn = "ubuntu-latest",
steps = Seq(
Step.SingleStep(
name = "Deploy to GitHub Pages",
uses = Some(ActionRef("actions/deploy-pages@v4")),
)
),
)
),
ciPostReleaseJobs := Nil,
// zio.sbt.githubactions.Job doesn't provide options for adding permissions and environment
// overriding ciGenerateGithubWorkflow as well as ciCheckGithubWorkflow to get both working
ciGenerateGithubWorkflow := ciGenerateGithubWorkflowV2.value,
ciCheckGithubWorkflow := Def.task {
import sys.process.*
val _ = ciGenerateGithubWorkflowV2.value

if ("git diff --exit-code".! == 1) {
sys.error(
"The ci.yml workflow is not up-to-date!\n" +
"Please run `sbt ciGenerateGithubWorkflow` and commit new changes."
)
}
},
scalafmt := true,
scalafmtSbtCheck := true,
scalafixDependencies ++= List(
Expand All @@ -109,6 +110,30 @@ inThisBuild(
)
)

lazy val ciGenerateGithubWorkflowV2 = Def.task {
val _ = ciGenerateGithubWorkflow.value

IO.append(
new File(s".github/workflows/ci.yml"),
"""| deploy-website:
| name: Deploy website
| runs-on: ubuntu-latest
| continue-on-error: false
| permissions:
| pages: write
| id-token: write
| environment:
| name: github-pages
| url: ${{ steps.deployment.outputs.page_url }}
| needs:
| - build
| steps:
| - name: Deploy to GitHub Pages
| uses: actions/deploy-pages@v4
|""".stripMargin,
)
}

lazy val commonSettings = List(
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
Expand Down

0 comments on commit c3f2c69

Please sign in to comment.