Browse Source

fix: support docs builds from worktrees (#6741)

In worktrees the .git is a file, not the whole git repo.
This fixes the build of the docs in worktree by mounting the
main repo too.

Signed-off-by: Jean-Philippe Evrard <jean-philippe.evrard+rochepub@external.roche.com>
Jean-Philippe Evrard 1 week ago
parent
commit
ad7c79158e
1 changed files with 5 additions and 0 deletions
  1. 5 0
      hack/api-docs/Makefile

+ 5 - 0
hack/api-docs/Makefile

@@ -37,6 +37,9 @@ GENROOT := $(ROOT)/site
 # Grab the uid/gid to fix permissions due to running in a docker container.
 GID := $(shell id -g)
 UID := $(shell id -u)
+GIT_DIR := $(shell git rev-parse --path-format=absolute --git-dir)
+GIT_COMMON_DIR := $(shell git rev-parse --path-format=absolute --git-common-dir)
+GIT_MOUNT := $(if $(filter $(GIT_DIR),$(GIT_COMMON_DIR)),,--mount type=bind,source=$(GIT_COMMON_DIR),target=$(GIT_COMMON_DIR))
 
 # SOURCES is a list of a source files used to generate the documentation.
 SOURCES := $(shell find $(SRCDIR) -name \*.md)
@@ -60,6 +63,7 @@ build: image generate $(SOURCES)
 	mkdir -p $(GENROOT)
 	$(DOCKER) run \
 	    --mount type=bind,source=$(ROOT),target=/repo \
+	    $(GIT_MOUNT) \
 		--sig-proxy=true \
 		--rm \
 		--env "GIT_COMMITTER_NAME=$(shell git config user.name)" \
@@ -72,6 +76,7 @@ build.publish: image generate $(SOURCES)
 	mkdir -p $(GENROOT)
 	$(DOCKER) run \
 	    --mount type=bind,source=$(ROOT),target=/repo \
+	    $(GIT_MOUNT) \
 		--sig-proxy=true \
 		--rm \
 		--user $(UID):$(GID) \