Repository navigation
Expand file tree
/
Copy pathbootstrap_doc_site_repo.sh
More file actions
executable file
·169 lines (146 loc) · 3.94 KB
/
Copy pathbootstrap_doc_site_repo.sh
File metadata and controls
executable file
·169 lines (146 loc) · 3.94 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
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
./bootstrap_doc_site_repo.sh [options] TARGET_DIR
Options:
--copy-site Copy the current MkDocs build output from ./site into TARGET_DIR
-h, --help Show this help message
Examples:
./bootstrap_doc_site_repo.sh ~/work/doc
./bootstrap_doc_site_repo.sh --copy-site ~/work/doc
EOF
}
COPY_SITE=false
TARGET_DIR=""
while [[ $# -gt 0 ]]; do
case "$1" in
--copy-site)
COPY_SITE=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
if [[ -n "$TARGET_DIR" ]]; then
echo "Only one TARGET_DIR may be provided." >&2
usage >&2
exit 1
fi
TARGET_DIR="$1"
shift
;;
esac
done
if [[ -z "$TARGET_DIR" ]]; then
usage >&2
exit 1
fi
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
cd "$REPO_ROOT"
mkdir -p "$TARGET_DIR"
TARGET_DIR="$(cd "$TARGET_DIR" && pwd)"
if [[ "$TARGET_DIR" == "$REPO_ROOT" ]]; then
echo "TARGET_DIR must not be the current source repository." >&2
exit 1
fi
cat > "$TARGET_DIR/.nojekyll" <<'EOF'
# GitHub Pages marker file for static site publishing.
EOF
cat > "$TARGET_DIR/index.html" <<'EOF'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>INFTY Docs</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
:root {
color-scheme: light;
--bg: #f4f1e8;
--panel: #fffdf8;
--ink: #1f2933;
--accent: #b45309;
--line: #e9dcc3;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
padding: 24px;
font-family: "Georgia", "Times New Roman", serif;
background:
radial-gradient(circle at top left, rgba(180, 83, 9, 0.12), transparent 30%),
linear-gradient(135deg, var(--bg), #f7f7f2);
color: var(--ink);
}
main {
max-width: 720px;
padding: 32px;
border: 1px solid var(--line);
border-radius: 20px;
background: var(--panel);
box-shadow: 0 24px 60px rgba(31, 41, 51, 0.08);
}
h1 {
margin-top: 0;
font-size: clamp(2rem, 5vw, 3rem);
}
p {
line-height: 1.65;
font-size: 1.05rem;
}
a {
color: var(--accent);
}
code {
padding: 0.1rem 0.35rem;
border-radius: 6px;
background: rgba(31, 41, 51, 0.06);
}
</style>
</head>
<body>
<main>
<h1>INFTY documentation is being prepared.</h1>
<p>
This repository is intended to host the published static site for
<a href="https://github.com/THUDM/INFTY">THUDM/INFTY</a>.
</p>
<p>
Once the source repository finishes its documentation workflow, this
placeholder page will be replaced automatically.
</p>
<p>
If you are setting up this repository for the first time, make sure GitHub
Pages is enabled for the <code>main</code> branch root and that the source
repository has a <code>DOC_REPO_TOKEN</code> secret with write access here.
</p>
</main>
</body>
</html>
EOF
if [[ "$COPY_SITE" == true ]]; then
if [[ ! -d "$REPO_ROOT/site" ]]; then
echo "No ./site directory found. Run 'mkdocs build --strict' first or omit --copy-site." >&2
exit 1
fi
rsync -av --exclude '.git/' "$REPO_ROOT/site/" "$TARGET_DIR/"
fi
cat <<EOF
Bootstrapped documentation site repository contents in:
$TARGET_DIR
Next steps:
1. Create the GitHub repository INFTY-AI/doc if it does not exist yet.
2. Commit and push the files in $TARGET_DIR to the main branch of that repository.
3. Enable GitHub Pages for the main branch root in INFTY-AI/doc.
4. Add a DOC_REPO_TOKEN secret to THUDM/INFTY with write access to INFTY-AI/doc.
5. Trigger the Documentation workflow in this source repository.
EOF