forked from gardener/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
179 lines (167 loc) · 6.92 KB
/
Makefile
File metadata and controls
179 lines (167 loc) · 6.92 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# SPDX-FileCopyrightText: 2018 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
# Default make target is `serve`
.PHONY:
@./scripts/serve
.PHONY: serve
# `make serve`: starts a `website-dev` container with hugo web server, serving the content from
# `/website` in this repository. Changes to content are reflected on the server in real time.
# Suitable for preview of content changes.
serve:
@./scripts/serve
# `make build`: builds the site without running a server. Suitable for quick validation.
.PHONY: build
build:
@./scripts/serve --build
# `make production`: (Experimental) creates a full-blown build with the content (same as Concourse)
# and runs a web server to preview the changes. Suitable for final quality check.
.PHONY: production
production:
@./scripts/serve --prod
# `make stop`: gracefully stops `website-dev` container (if it was run).
.PHONY: stop
stop:
@./scripts/stop -c=website-dev
.PHONY: check-manifest
check-manifest:
@.ci/check-manifest-entrypoint
.PHONY: test
test:
@python3 test/selenium-test.py
### vitepress ###
.PHONY: docforge
docforge: docforge-download ## Check environment and run docforge
@echo "Checking environment variables for docforge..."
@if [ -f .env ]; then \
export $$(grep -v '^#' .env | grep -v '^$$' | xargs); \
fi
@if [ -z "$$DOCFORGE_CONFIG" ]; then \
echo "ERROR: DOCFORGE_CONFIG environment variable is not set."; \
echo "Please add the following to your ~/.bashrc or ~/.zshrc:"; \
echo " export DOCFORGE_CONFIG=.docforge/config.yaml"; \
echo "Then run: source ~/.bashrc (or ~/.zshrc)"; \
exit 1; \
fi
@if [ -z "$$GITHUB_OAUTH_TOKEN" ]; then \
echo "ERROR: GITHUB_OAUTH_TOKEN environment variable is not set."; \
echo "Please create a token (see docs/resources/github-token-guide.md)"; \
echo "Then add it to your ~/.bashrc or ~/.zshrc:"; \
echo " export GITHUB_OAUTH_TOKEN=your_token"; \
echo "Then run: source ~/.bashrc (or ~/.zshrc)"; \
exit 1; \
fi
@echo "Environment check passed:"
@echo "DOCFORGE_CONFIG: $$DOCFORGE_CONFIG"
@echo "GITHUB_OAUTH_TOKEN: $${GITHUB_OAUTH_TOKEN:0:5}..."
@if [ -d "hugo/content" ]; then \
read -p "Content directory already exists. Do you want to run docforge again to update it? (y/n): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "Running docforge..."; \
./bin/docforge; \
else \
echo "Skipping docforge execution."; \
fi; \
else \
echo "Content directory does not exist. Running docforge..."; \
./bin/docforge; \
fi
.PHONY: docforge-download
docforge-download: ## Download the appropriate docforge binary for the current OS if not present
@echo "Creating bin directory if it doesn't exist..."
@mkdir -p bin
@echo "Detecting OS and architecture..."
@if [ "$$(uname)" = "Darwin" ]; then \
if [ "$$(uname -m)" = "arm64" ]; then \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for macOS ARM64 already exists and is executable."; \
else \
echo "Downloading docforge for macOS ARM64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-darwin-arm64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
else \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for macOS AMD64 already exists and is executable."; \
else \
echo "Downloading docforge for macOS AMD64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-darwin-amd64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
fi; \
elif [ "$$(uname)" = "Linux" ]; then \
if [ "$$(uname -m)" = "aarch64" ] || [ "$$(uname -m)" = "arm64" ]; then \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for Linux ARM64 already exists and is executable."; \
else \
echo "Downloading docforge for Linux ARM64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-linux-arm64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
else \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for Linux AMD64 already exists and is executable."; \
else \
echo "Downloading docforge for Linux AMD64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-linux-amd64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
fi; \
elif [[ "$$(uname -s)" == MINGW* ]] || [[ "$$(uname -s)" == CYGWIN* ]]; then \
if [ -f bin/docforge.exe ]; then \
echo "Docforge for Windows already exists."; \
else \
echo "Downloading docforge for Windows..."; \
curl -L -o bin/docforge.exe https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-windows-386.exe; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
else \
echo "Unsupported OS. Please download docforge manually from https://github.com/gardener/docforge/releases"; \
exit 1; \
fi
.PHONY: docforge-run
docforge-run: docforge-download ## Check environment and run docforge with custom parameters
@echo "Checking environment variables for docforge..."
@if [ -z "$$DOCFORGE_CONFIG" ]; then \
echo "ERROR: DOCFORGE_CONFIG environment variable is not set."; \
echo "Please add the following to your ~/.bashrc or ~/.zshrc:"; \
echo " export DOCFORGE_CONFIG=.docforge/config.yaml"; \
echo "Then run: source ~/.bashrc (or ~/.zshrc)"; \
exit 1; \
fi
@if [ -z "$$GITHUB_OAUTH_TOKEN" ]; then \
echo "ERROR: GITHUB_OAUTH_TOKEN environment variable is not set."; \
echo "Please create a token (see docs/resources/github-token-guide.md)"; \
echo "Then add it to your ~/.bashrc or ~/.zshrc:"; \
echo " export GITHUB_OAUTH_TOKEN=your_token"; \
echo "Then run: source ~/.bashrc (or ~/.zshrc)"; \
exit 1; \
fi
@echo "Environment check passed:"
@if [ -d "content" ]; then \
read -p "Content directory already exists. Do you want to run docforge again to update it? (y/n): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "Running docforge..."; \
./bin/docforge; \
else \
echo "Skipping docforge execution."; \
fi; \
else \
echo "Content directory does not exist. Running docforge..."; \
./bin/docforge; \
fi
# VitePress documentation targets
.PHONY: docs-dev
docs-dev: docforge-run ## Run docforge and start the VitePress development server
@echo "Building VitePress dev environment Docker image..."
docker build --no-cache -t gardener_docs_dev -f Dockerfile.dev . --load
@echo "Starting VitePress development server on port 5173..."
docker run --rm -p 5173:5173 -v `pwd`/:/app gardener_docs_dev