Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hugo version check and theme update to Makefile #6518

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
HUGO?=hugo
HUGO_IMG?=hugomods/hugo:0.134.1
HUGO_VERSION?=$(shell hugo version 2>/dev/null | awk '{print $$2}' | cut -d '.' -f 2)
HUGO_IMG?=hugomods/hugo:std-go-git-0.134.3

THEME_MODULE = github.com/nginxinc/nginx-hugo-theme
THEME_VERSION ?= $(shell curl -s https://api.github.com/repos/nginxinc/nginx-hugo-theme/releases/latest | jq -r ".tag_name")

ifeq (, $(shell ${HUGO} version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
$(error Docker and Hugo are not installed. Hugo (<0.91) or Docker are required to build the local preview.)
HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo

ifeq ($(shell [ $(HUGO_VERSION) -gt 133 2>/dev/null ] && echo true || echo false), true)
$(info Hugo is available and has a version greater than 133. Proceeding with build.)
else
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} hugo --bind 0.0.0.0 -p 1313
$(warning Hugo is not available or using a version less than 134. Attempting to use docker. HUGO_VERSION=$(HUGO_VERSION))
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} /src/hugo-entrypoint.sh
ifeq (, $(shell docker version 2> /dev/null))
$(error Hugo (>0.134) or Docker are required to build the local previews.)
endif
endif
endif

HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo
j1m-ryan marked this conversation as resolved.
Show resolved Hide resolved

MARKDOWNLINT?=markdownlint
MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest

ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
$(error Docker and markdownlint are not installed. markdownlint or Docker are required to lint.)
endif
else
MARKDOWNLINT=docker run --rm -i -v ${CURDIR}:/src --workdir /src ${MARKDOWNLINT_IMG}
endif
endif

MARKDOWNLINKCHECK?=markdown-link-check
MARKDOWNLINKCHECK_IMG?=ghcr.io/tcort/markdown-link-check:stable

ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
$(error Docker and markdown-link-check are not installed. markdown-link-check or Docker are required to check links.)
endif
else
MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/site --workdir /site ${MARKDOWNLINKCHECK_IMG}
MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG}
endif
endif


.PHONY: docs docs-draft docs-local clean hugo-get hugo-tidy lint-markdown link-check

Expand All @@ -51,11 +52,10 @@ drafts:
${HUGO} --bind 0.0.0.0 -p 1313 server -D --disableFastRender

clean:
hugo mod clean
[ -d "public" ] && rm -rf "public"

hugo-get:
hugo mod get $(THEME_MODULE)@$(THEME_VERSION)
hugo mod get -u github.com/nginxinc/nginx-hugo-theme

hugo-tidy:
hugo mod tidy
Expand Down
4 changes: 2 additions & 2 deletions docs/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/nginxinc/kubernetes-ingress/docs

go 1.19
go 1.23

require github.com/nginxinc/nginx-hugo-theme v0.41.17 // indirect
require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect
4 changes: 2 additions & 2 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nginxinc/nginx-hugo-theme v0.41.17 h1:KtF0TFQYXmVratjKVGEodWYFNbtxeOdrZLa9zi70BtA=
github.com/nginxinc/nginx-hugo-theme v0.41.17/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
github.com/nginxinc/nginx-hugo-theme v0.41.19 h1:CyZOhU8q0p3nQ+ZTFRx7c/Dq9rxV1mShADIHz0vDoHo=
github.com/nginxinc/nginx-hugo-theme v0.41.19/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
4 changes: 4 additions & 0 deletions docs/hugo-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

hugo mod get -u github.com/nginxinc/nginx-hugo-theme
hugo $*