diff --git a/Makefile b/Makefile index ec78921fa..d9f3bb686 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,37 @@ -PLAYBOOK := local-antora-playbook.yml -ANTORAFLAGS := +CURRENT_COMMIT := $(shell git rev-parse HEAD) -build: +build-dev: build-ui + node_modules/.bin/antora generate local-antora-playbook.yml + +build-prod: build-ui + node_modules/.bin/antora generate antora-playbook.yml --fetch + +build-ui: node_modules/.bin/gulp --cwd ui bundle - node_modules/.bin/antora generate $(PLAYBOOK) $(ANTORAFLAGS) -.PHONY: clean clean: rm -r build # 'cache' is the configured cache dir in the playbook rm -r cache -.PHONY: build +# The netlify repo is checked out without any blobs. This script +# iterates through the release branches and checks them out one-by-one +# to fetch all the files. +# Then we can build directly from here, making it possible to build +# with antora using the HEAD (enabling branch previews!) +netlify-fetch: + git submodule update --init --recursive + # netlify messes with some files, restore everything to how it was: + git reset --hard --recurse-submodule + # fetch, because netlify does caching and we want to get the latest commits + git fetch --all + # checkout all release branches once, so we fetch the files + for remote in $(shell git branch -r | grep release/); do \ + git checkout --recurse-submodules "$${remote#origin/}" ;\ + done + # go back to the initial commit to start the build + git -c advice.detachedHead=false checkout --recurse-submodules $(CURRENT_COMMIT) + +netlify-build: netlify-fetch build-prod + +.PHONY: build-dev build-prod build-ui clean netlify-build netlify-fetch diff --git a/antora-playbook.yml b/antora-playbook.yml index 6521fea91..59a26128e 100644 --- a/antora-playbook.yml +++ b/antora-playbook.yml @@ -15,7 +15,7 @@ urls: content: sources: - - url: https://github.com/stackabletech/documentation.git + - url: . branches: - HEAD - release/23.4 diff --git a/netlify.toml b/netlify.toml index 8adf31c96..acd39ef84 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,7 @@ +[build] + command = "make netlify-build" + publish = "build/site" + [[redirects]] from = "/airflow/nightly/*" to = "/home/nightly/airflow/:splat"