-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
100 lines (79 loc) · 3.77 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
.DEFAULT_GOAL := help
.PHONY: test preview build theme spell node_modules
word-dot = $(word $2,$(subst ., ,$1))
hugo_prod := 0.133.0
hugo_local := $(shell hugo version | awk -F v '{print substr($$2,1,7)}')
#help: @ List available tasks on this project
help:
@echo "user tasks:"
@grep -E '[a-zA-Z\.\-]+:.*?@ .*$$' $(MAKEFILE_LIST)| tr -d '#' | awk 'BEGIN {FS = ":.*?@ "}; {printf "\t\033[32m%-30s\033[0m %s\n", $$1, $$2}'
@echo
#theme: @ runs git module to update the theme
theme:
if [ -d ".git/modules/themes/docsy/assets/" ]; then rm -rf .git/modules && rm -rf themes/docsy && mkdir themes/docsy; fi
git submodule update --init --recursive
#npm: @ runs npm ci to install dependencies from package-lock.json
npm: theme
npm ci
#hugo-check: @ checks system version of hugo
hugo-check:
ifeq ($(hugo_local),$(hugo_prod))
@echo hugo $(hugo_local) validated
else
@echo $@ failure: Your hugo version \($(hugo_local)\) does not match production \($(hugo_prod)\)
@echo run \'brew upgrade hugo\' or download and install the extended version from the releases page \(https://github.com/gohugoio/hugo/releases/tag/v$(hugo_prod)\).
@exit 1
endif
#preview: @ preview hugo
preview: hugo-check npm
ulimit -n 65535; hugo server -b http://localhost:1313/
#preview-ip: @ preview hugo with IP
preview-ip: npm
ulimit -n 65535; hugo server --panicOnWarning --bind 0.0.0.0 -b http://${MYIP}:1313/developer
#build: @ build site into `public` directory
build: hugo-check npm
hugo -b http://localhost:1313/
#test: @ runs act to simulate a github pull request test suite
test: npm
act pull_request
#clean: @ Remove /public, test containers, etc
clean:
rm -rf public
docker rmi -f act-github-actions-topic-check-dockeraction act-github-actions-link-check-dockeraction act-github-actions-spell-check-dockeraction catthehacker/ubuntu:act-latest
#spell: @ runs act to perform spellcheck
spell: npm
act -j spell-check
#local: @ used for running local netlify dev server
local: function-config
hugo server -w -b http://localhost:1313/
#function-config: @ sets the function config variables during build
function-config: npm
ifeq ($(CONTEXT), production)
awk -v a="${CONTEXT}" '{gsub(/CONTEXT_PLACEHOLDER/,a)}1' netlify/functions/util/config.js.ph | awk -v a="${URL}" '{gsub(/DEPLOY_PRIME_URL_PLACEHOLDER/,a)}1' > netlify/functions/util/config.js
else
ifeq ($(CONTEXT), deploy-preview)
awk -v a="${CONTEXT}" '{gsub(/CONTEXT_PLACEHOLDER/,a)}1' netlify/functions/util/config.js.ph | awk -v a="${DEPLOY_PRIME_URL}" '{gsub(/DEPLOY_PRIME_URL_PLACEHOLDER/,a)}1' > netlify/functions/util/config.js
else
awk -v a="${CONTEXT}" '{gsub(/CONTEXT_PLACEHOLDER/,a)}1' netlify/functions/util/config.js.ph | awk -v a="http://localhost:8888" '{gsub(/DEPLOY_PRIME_URL_PLACEHOLDER/,a)}1' > netlify/functions/util/config.js
endif
endif
#guide.wi: @ creates a what-is guide. example: make guide.wi.spring.spring-boot-what-is
guide.wi.%:
hugo new guides/$(call word-dot,$*,1)/$(call word-dot,$*,2).md -k guide-what-is
#guide.gs: @ creates a getting started guide. example: make guide.gs.spring.spring-boot-gs
guide.gs.%:
hugo new guides/$(call word-dot,$*,1)/$(call word-dot,$*,2).md -k guide-gs
#blog: @ creates a blog post. example: make blog.writing-makefiles
blog.%:
hugo new blog/$(call word-dot,$*,1).md -k blog-post
#sample: @ creates an example. example: make sample.example-makefile
sample.%:
hugo new examples/$(call word-dot,$*,1).md -k example
#video: @ creates a video. example: make video.demo-writing-makefiles
video.%:
hugo new videos/$(call word-dot,$*,1).md -k video
#audit: @ runs a content audit on all guides and blogs. example: make audit
audit:
cd .github/actions/audit/src && bundle install
mkdir audit
ruby .github/actions/audit/src/audit.rb -s . -o audit/audit.csv -t audit/tags.csv --topics audit/topics.csv --errors audit/errors.csv