Skip to content

Commit 552c70f

Browse files
committed
make it deployable
1 parent 280b071 commit 552c70f

7 files changed

+62
-16
lines changed

.envrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export FASTLY_SERVICE_ID="lACFUzQjUGLnZsvoHgcnx6"
2+
3+
[[ -f .envrc.local ]] && source .envrc.local

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ docs/
88

99
# mkdocs cache
1010
.cache
11+
12+
# dev envrc
13+
.envrc.local

build-all.sh

+6-14
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,16 @@ cleanup() {
99

1010
trap cleanup INT
1111

12-
export INSIDERS=true
13-
#
14-
# Build main site
15-
# export BUILD_ONLY_LOCALE=en
16-
CLEAN="${CLEAN:-1}"
17-
[[ $CLEAN ]] && mkdocs build -d build/site
18-
19-
# for locale in $(yq -r '.plugins[] | select(type == "object" and has("i18n")) | .i18n.languages[].locale' < mkdocs.yml | grep -v 'en'); do
20-
# export BUILD_ONLY_LOCALE=$locale
21-
#
22-
# # Run mkdocs build for the current locale
23-
# mkdocs build -d "site/$locale"
24-
# done
12+
# Build the site
13+
mkdocs build -d build/site
2514

2615
# hardlink duplicates
2716
hardlink -t build/site
2817

2918
# minify everything
3019
test -d build/minified || minify -r --sync --preserve=all -o build/minified build/site
3120

32-
du -hs build/*
21+
# remove locales from minified (Fastly) site
22+
for locale in $(yq -r '.plugins[] | select(type == "object" and has("i18n")) | .i18n.languages[].locale' < mkdocs.yml | grep -v 'en'); do
23+
rm -fr "build/minified/site/$locale"
24+
done

deploy.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
cleanup() {
4+
echo -e "\nScript interrupted. Exiting..."
5+
exit 1
6+
}
7+
8+
trap cleanup INT
9+
10+
FASTLY=$(command -v fastly || echo "./compute-js/bin/fastly")
11+
12+
test -x "$FASTLY" || exit 2
13+
14+
source .envrc
15+
16+
if [[ -z $FASTLY_API_TOKEN ]]; then
17+
# shellcheck disable=2016
18+
echo 'missing $FASTLY_API_TOKEN'
19+
fi
20+
if [[ -z $FASTLY_SERVICE_ID ]]; then
21+
# shellcheck disable=2016
22+
echo 'missing $FASTLY_API_TOKEN'
23+
fi
24+
25+
pushd compute-js || exit $?
26+
$FASTLY compute build || exit $?
27+
$FASTLY compute deploy -p pkg/resf-rocky-linux-docs.tar.gz
28+
29+
popd || exit

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"scripts": {
66
"load-docs": "rm -rf docs; git clone https://github.com/rocky-linux/documentation docs",
77
"dev": "mkdocs serve",
8-
"build": "pip install 'urllib3<2' && mkdocs build"
8+
"build": "bash setup-deps.sh && bash build-all.sh && bash deploy.sh"
99
}
1010
}

setup-deps.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
cleanup() {
4+
echo -e "\nScript interrupted. Exiting..."
5+
exit 1
6+
}
7+
8+
trap cleanup INT
9+
10+
pip install 'urllib3<2' yq
11+
pip install -r requirements.txt
12+
13+
# Only install insiders package if it's available
14+
if [[ -n "$GH_TOKEN" ]]; then
15+
pip install "git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git"
16+
fi
17+
18+
test -f compute-js/bin/fastly || ( curl -Ls https://github.com/fastly/cli/releases/download/v10.8.3/fastly_v10.8.3_linux-amd64.tar.gz | tar -xzf /dev/stdin -C compute-js/bin/ )

vercel.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"trailingSlash": true
2+
"trailingSlash": true,
3+
"outputDirectory": "build/site"
34
}

0 commit comments

Comments
 (0)