-
Notifications
You must be signed in to change notification settings - Fork 799
/
website.mk
144 lines (121 loc) · 6.64 KB
/
website.mk
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright 2018 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# __ __ _ _ _
# \ \ / /__| |__ ___(_) |_ ___
# \ \ /\ / / _ \ '_ \/ __| | __/ _ \
# \ V V / __/ |_) \__ \ | |_ __/
# \_/\_/ \___|_.__/|___/_|\__\___|
#
#
# Website targets
#
# generate the latest website
site-server: ARGS ?=-F
site-server: ENV ?= RELEASE_VERSION="$(base_version)" RELEASE_BRANCH=main
site-server: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) -p 1313:1313 $(build_tag) bash -c \
"$(git_safe) && $(ENV) hugo server --watch --baseURL=http://localhost:1313/ --bind=0.0.0.0 $(ARGS)"
site-static: ensure-build-image
-docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) rm -r ./public
-mkdir $(agones_path)/site/public
# for some reason, this only work locally
# postcss-cli@8.3.1 broke things, so pinning the version
docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) \
bash -c "npm list postcss-cli || npm install postcss-cli@8.3.0"
# autoprefixer 10.0.0 broke things, so pinning the version
docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) \
bash -c "npm list autoprefixer || npm install autoprefixer@9.8.6"
docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
"$(git_safe) && $(ENV) hugo --config=config.toml $(ARGS)"
site-gen-app-yaml: SERVICE ?= default
site-gen-app-yaml:
docker run --rm $(common_mounts) --workdir=$(mount_path)/site $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
"SERVICE=$(SERVICE) envsubst < app.yaml > .app.yaml"
site-deploy: site-gen-app-yaml site-static
docker run --network=cloudbuild -t --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) \
-e GO111MODULE=on -e SHORT_SHA=$(shell git rev-parse --short=7 HEAD) $(build_tag) bash -c \
'printenv && cd ./site && \
gcloud app deploy .app.yaml --no-promote --quiet --version=$$SHORT_SHA'
site-static-preview:
$(MAKE) site-static ARGS="-F" ENV="RELEASE_VERSION=$(base_version) RELEASE_BRANCH=main"
site-deploy-preview: site-static-preview
$(MAKE) site-deploy SERVICE=preview
hugo-test: site-static-preview
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; \
do echo "Html Test: Attempt $$i" && \
docker run --rm -t -e "TERM=xterm-256color" $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
"mkdir -p /tmp/website && cp -r $(mount_path)/site/public /tmp/website/site && htmltest -c $(mount_path)/site/htmltest.yaml /tmp/website" && \
break || sleep 60 && false; done
site-test:
# generate actual html and run test against - provides a more accurate tests
$(MAKE) test-gen-api-docs
$(MAKE) hugo-test
# generate site images, if they don't exist
site-images: $(site_path)/static/diagrams/gameserver-states.dot.png
site-images: $(site_path)/static/diagrams/eviction-decision.dot.png
site-images: ${site_path}/static/diagrams/system-diagram.dot.png
site-images: $(site_path)/static/diagrams/gameserver-lifecycle.puml.png
site-images: $(site_path)/static/diagrams/gameserver-reserved.puml.png
site-images: $(site_path)/static/diagrams/canary-testing.puml.png
site-images: $(site_path)/static/diagrams/allocation-player-capacity.puml.png
site-images: $(site_path)/static/diagrams/reusing-gameservers.puml.png
site-images: $(site_path)/static/diagrams/high-density.puml.png
# generate pngs from dot files
%.dot.png: %.dot
docker run -i --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
'dot -Tpng /dev/stdin' < $< > $@.tmp && mv $@.tmp $@
# general pngs from puml files
%.puml.png: %.puml
docker run -i --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
'plantuml -pipe' < $< > $@
# Path to a file and docker command
REL_PATH := content/en/docs/Reference/agones_crd_api_reference.html
GEN_API_DOCS := docker run -e FILE="$(mount_path)/site/$(REL_PATH)" -e VERSION=${base_version} --rm -i $(common_mounts) $(build_tag) bash -c "/go/src/agones.dev/agones/site/gen-api-docs.sh"
# generate Agones CRD reference docs
gen-api-docs: ensure-build-image
$(GEN_API_DOCS)
# test generated Agones CRD reference docs
test-gen-api-docs: expected_docs := $(site_path)/$(REL_PATH)
test-gen-api-docs: ensure-build-image
cp $(expected_docs) /tmp/generated.html
sort /tmp/generated.html > /tmp/generated.html.sorted
$(GEN_API_DOCS)
sort $(expected_docs) > /tmp/result.sorted
diff -bB /tmp/result.sorted /tmp/generated.html.sorted
# Remove feature expiry/publish version shortcodes update in site/content/en/docs
feature-shortcode-update: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run build/scripts/feature-shortcode-update/main.go -version=$(version)
# update SDKS/Install version
sdk-update-version: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run build/scripts/sdk-update-version/main.go -release-stage=$(release_stage) -version=$(version)
# delete "data-proofer-ignore" attribute from previous release blog.
del-data-proofer-ignore: FILENAME ?= ""
del-data-proofer-ignore: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run build/scripts/remove-data-proofer-ignore/main.go -file=$(FILENAME)
# update release version and replicate data between dev and prod in site/config.toml
site-config-update-version: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run build/scripts/site-config-update-version/main.go
# Delete old release version in site/layouts/partials/navbar.html.
update-navbar-version: FILENAME ?= ""
update-navbar-version: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run build/scripts/update-navbar-version/main.go -file=$(FILENAME)
# bump examples image
bump-image: ensure-build-image
docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) \
go run build/scripts/bump-image/main.go -imageName=$(IMAGENAME) -version=$(VERSION)