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 <milosthegajdos@gmail.com>
This commit is contained in:
Milos Gajdos 2023-10-13 09:12:32 +01:00 committed by James Hewitt
parent c78d6f99ae
commit 777ad03208
No known key found for this signature in database
GPG key ID: EA6C3C654B6193E4
3 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,5 @@
name: docs
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -7,6 +9,8 @@ on:
branches: branches:
- main - main
paths: paths:
- .github/workflows/docs.yml
- dockerfiles/docs.Dockerfile
- docs/** - docs/**
workflow_dispatch: workflow_dispatch:
@ -20,6 +24,9 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- name: Build docs - name: Build docs
@ -31,6 +38,13 @@ jobs:
set: | set: |
*.cache-from=type=gha,scope=docs *.cache-from=type=gha,scope=docs
*.cache-to=type=gha,scope=docs,mode=max *.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 - name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2 uses: actions/upload-pages-artifact@v2
with: with:

View file

@ -95,8 +95,15 @@ target "image-all" {
] ]
} }
variable "DOCS_BASEURL" {
default = null
}
target "_common_docs" { target "_common_docs" {
dockerfile = "./dockerfiles/docs.Dockerfile" dockerfile = "./dockerfiles/docs.Dockerfile"
args = {
DOCS_BASEURL = DOCS_BASEURL
}
} }
target "docs-export" { target "docs-export" {

View file

@ -16,8 +16,9 @@ COPY --from=hugo $GOPATH/bin/hugo /bin/hugo
WORKDIR /src WORKDIR /src
FROM build-base AS build FROM build-base AS build
ARG DOCS_BASEURL=/
RUN --mount=type=bind,rw,source=docs,target=. \ 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 FROM build-base AS server
COPY docs . COPY docs .