forked from gardener/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (135 loc) · 5.65 KB
/
Makefile
File metadata and controls
139 lines (135 loc) · 5.65 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
# SPDX-FileCopyrightText: 2018 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
.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
.PHONY: preview
preview:
@chmod +x hack/preview.sh
@hack/preview.sh