From 777ad03208f01efe69b4568e96335a6e0f92c8a0 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Fri, 13 Oct 2023 09:12:32 +0100 Subject: [PATCH] Update docs GHA Add missing steps to the job, pick up the path automatically, trigger the job on config file changes. Signed-off-by: Milos Gajdos --- .github/workflows/docs.yml | 14 ++++++++++++++ docker-bake.hcl | 7 +++++++ dockerfiles/docs.Dockerfile | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f4542f3a..c37f59e0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,3 +1,5 @@ +name: docs + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -7,6 +9,8 @@ on: branches: - main paths: + - .github/workflows/docs.yml + - dockerfiles/docs.Dockerfile - docs/** workflow_dispatch: @@ -20,6 +24,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build docs @@ -31,6 +38,13 @@ jobs: set: | *.cache-from=type=gha,scope=docs *.cache-to=type=gha,scope=docs,mode=max + env: + DOCS_BASEURL: ${{ steps.pages.outputs.base_path }} + - name: Fix permissions + run: | + chmod -c -R +rX "./build/docs" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done - name: Upload Pages artifact uses: actions/upload-pages-artifact@v2 with: diff --git a/docker-bake.hcl b/docker-bake.hcl index 2b7f25d6..0587572a 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -95,8 +95,15 @@ target "image-all" { ] } +variable "DOCS_BASEURL" { + default = null +} + target "_common_docs" { dockerfile = "./dockerfiles/docs.Dockerfile" + args = { + DOCS_BASEURL = DOCS_BASEURL + } } target "docs-export" { diff --git a/dockerfiles/docs.Dockerfile b/dockerfiles/docs.Dockerfile index 4d351b69..e1d728a1 100644 --- a/dockerfiles/docs.Dockerfile +++ b/dockerfiles/docs.Dockerfile @@ -16,8 +16,9 @@ COPY --from=hugo $GOPATH/bin/hugo /bin/hugo WORKDIR /src FROM build-base AS build +ARG DOCS_BASEURL=/ RUN --mount=type=bind,rw,source=docs,target=. \ - hugo --gc --minify --destination /out + hugo --gc --minify --destination /out -b $DOCS_BASEURL FROM build-base AS server COPY docs .