mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
a7fa31d56e
Fixes https://github.com/open-policy-agent/opa/issues/6269 This fixes the issue by using the builtin_metadata.json file from each version, the assumption that docs content that depends on the data doesn't exist before this file was introduced. I have removed the 'available' check since we haven't consistently updated the file in the past, e.g. * https://github.com/open-policy-agent/opa/blob/v0.41.0/builtin_metadata.json#L12710 * https://github.com/open-policy-agent/opa/blob/v0.57.0/builtin_metadata.json#L563 These examples show that sometimes the current version is included, other times the file is updated after the release. Video showing the correct content being displayed for various versions: https://github.com/open-policy-agent/opa/assets/1774239/abf1af7d-9c59-4223-a019-c73d7550b322 To locally test this: ``` git clean -dfx cd docs make generate hugo-production-build hugo server --source website --contentDir generated --ignoreCache --minify ``` Signed-off-by: Charlie Egan <charlie@styra.com>
92 lines
2.6 KiB
Makefile
92 lines
2.6 KiB
Makefile
DEPLOY_PRIME_URL ?= "http://localhost:8888"
|
|
|
|
######################################################
|
|
#
|
|
# Development targets
|
|
#
|
|
######################################################
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f $(CURDIR)/website/data/releases.yaml
|
|
rm -f $(CURDIR)/website/data/builtin_metadata.json
|
|
rm -rf $(CURDIR)/website/generated
|
|
rm -rf $(CURDIR)/website/public
|
|
rm -rf $(CURDIR)/website/resources
|
|
rm -rf $(CURDIR)/website/scripts/live-blocks/opa_versions/latest-*
|
|
|
|
.PHONY: generate-cli-docs
|
|
generate-cli-docs:
|
|
$(CURDIR)/../build/gen-cli-docs.sh "$(CURDIR)/content"
|
|
|
|
.PHONY: generate
|
|
generate: generate-cli-docs copy-hugo-static-content
|
|
$(CURDIR)/website/scripts/load-docs.sh
|
|
|
|
.PHONY: copy-hugo-static-content
|
|
copy-hugo-static-content:
|
|
mkdir -p $(CURDIR)/website/generated/
|
|
cp -r $(CURDIR)/website/content/* $(CURDIR)/website/generated/
|
|
|
|
.PHONY: dev-generate
|
|
dev-generate: generate-cli-docs copy-hugo-static-content
|
|
DEV=true $(CURDIR)/website/scripts/load-docs.sh
|
|
|
|
# The website has some npm dependencies saved in ./website/node_modules
|
|
# As well as dependencies required for the "live-blocks".
|
|
# Use this target to update them as needed.
|
|
.PHONY: install-deps
|
|
install-deps: live-blocks-install-deps
|
|
npm install
|
|
|
|
# The live-blocks-% pattern target will shim to the
|
|
# npm scripts in ./website/scripts/live-blocks
|
|
# NOTE(sr): we'll avoid an API call if we make use of releases.yaml to determine the latest release
|
|
.PHONY: live-blocks-%
|
|
live-blocks-%:
|
|
cd $(CURDIR)/website/scripts/live-blocks && LATEST=$(shell sed -n '2s/- //p' $(CURDIR)/website/data/releases.yaml) npm run $*
|
|
|
|
.PHONY: serve-local
|
|
serve-local: dev-build
|
|
# must be run from root of repo for
|
|
# the netlify.toml config to work
|
|
cd $(CURDIR)/.. && netlify dev --offline --dir $(CURDIR)/website/public
|
|
|
|
.PHONY: serve-remote
|
|
serve-remote: production-build
|
|
# must be run from root of repo for
|
|
# the netlify.toml config to work
|
|
cd $(CURDIR)/.. && netlify deploy
|
|
|
|
.PHONY: dev-build
|
|
dev-build: clean dev-generate hugo-production-build live-blocks-inject
|
|
|
|
######################################################
|
|
#
|
|
# CI targets
|
|
#
|
|
######################################################
|
|
|
|
.PHONY: hugo-production-build
|
|
hugo-production-build:
|
|
hugo \
|
|
--source $(CURDIR)/website \
|
|
--contentDir generated \
|
|
--ignoreCache \
|
|
--minify
|
|
|
|
.PHONY: production-build
|
|
production-build: clean generate hugo-production-build
|
|
make live-blocks-inject
|
|
|
|
.PHONY: preview-build
|
|
preview-build:
|
|
hugo \
|
|
--source $(CURDIR)/website \
|
|
--contentDir generated \
|
|
--baseURL $(DEPLOY_PRIME_URL) \
|
|
--buildDrafts \
|
|
--buildFuture \
|
|
--ignoreCache
|
|
make live-blocks-inject
|