This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathMakefile
101 lines (79 loc) · 3.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
HUGO?=hugo
HUGO_IMG?=hugomods/hugo:0.115.3
THEME_MODULE = github.com/nginxinc/nginx-hugo-theme
## Pulls the current theme version from the Netlify settings
THEME_VERSION = $(NGINX_THEME_VERSION)
# if there's no local hugo, fallback to docker
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.)
else
HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} hugo --bind 0.0.0.0 -p 1313
endif
endif
MARKDOWNLINT?=markdownlint
MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest
# if there's no local markdownlint, fallback to docker
ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
ifneq (, $(shell $(NETLIFY) "true"))
$(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
# if there's no local markdown-link-check, fallback to docker
ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null))
ifeq (, $(shell docker version 2> /dev/null))
ifneq (, $(shell $(NETLIFY) "true"))
$(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}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG}
endif
endif
.PHONY: all clean hugo-mod build-production build-staging hugo-server-drafts hugo-server netlify
all: hugo-mod build-production
all-staging: hugo-mod build-staging
all-dev: hugo-mod build-dev
# Removes the public directory generated by the `hugo` command
clean:
if [[ -d ${PWD}/public ]] ; then rm -rf ${PWD}/public && echo "Removed public directory" ; else echo "Did not find a public directory to remove" ; fi
hugo-mod:
hugo mod get $(THEME_MODULE)@v$(THEME_VERSION)
# Builds using the Hugo "staging" environment
# For deploys to docs.nginx.com only
build-production: hugo-mod
hugo --gc -e production
# Builds using the Hugo "staging" environment
# For deploys to docs-staging.nginx.com only
build-staging: hugo-mod
hugo --gc -e staging
# Builds using the Hugo "development" environment
# For deploys to docs-dev.nginx.com only
build-dev: hugo-mod
hugo --gc -e development
# Runs the Hugo server with content marked as draft
# Serves docs at localhost:1313
docs-drafts:
${HUGO} server -D --disableFastRender
docs-local: clean
${HUGO}
# Runs the Hugo server
# Serves docs at localhost:1313
docs:
${HUGO} server --disableFastRender
lint-markdown:
${MARKDOWNLINT} -c .markdownlint.yaml -- content
link-check:
${MARKDOWNLINKCHECK} $(shell find content -name '*.md')
# Can be used to deploy to netlify from your local
# development environment.
# Requires a netlify login.
netlify: clean
netlify deploy --build -d public --alias $(shell git branch --show-current)-branch
deploy-preview: hugo-mod
hugo --gc -d public/nginx-amplify -b ${NETLIFY_DEPLOY_URL}/nginx-amplify