forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-site.sh
executable file
·65 lines (54 loc) · 1.98 KB
/
publish-site.sh
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
#!/bin/bash
set -e
# This script runs Jekyll to translate our Markdown files at "doc/" into static web pages.
# The pages will be updated in "docs/" (note the extra s).
# The changes will go live on www.vitess.io when the commit is merged into the "master" branch.
#
# Run the script with "--docker" to run Jekyll within Docker (recommended).
if [[ -n "$(git status --porcelain)" ]]; then
echo "ERROR: Your working directory is not clean."
echo
echo "Please make sure that all pending changes are comitted or stashed away."
echo "This is a safe guard to avoid that the 'git add -A' in the 'docs/' directory adds files which were not generated by Jekyll."
exit 1
fi
# Output directory were the static web pages will be written to.
# Note: The directory is relative to $VTTOP.
website_dir="docs"
# compile to html pages
if [[ "$1" == "--docker" ]]; then
docker run -ti --rm --name=vitess_publish_site -v $VTTOP:/vttop vitess/publish-site bash -c \
"cd /vttop/vitess.io && \
bundle install && \
bundle exec jekyll build --destination ../$website_dir && \
chown -R $UID /vttop/vitess.io /vttop/$website_dir"
else
(cd vitess.io && bundle install && bundle exec jekyll build --destination ../$website_dir)
fi
# Change to docs/ directory.
pushd $website_dir >/dev/null
# Restore README.md because it gets deleted by Jekyll.
git checkout README.md
# pre-commit checks
set +e
list=$(find . -name '*.html' ! -path '*/vendor/*' ! -path '*/web/*' | xargs grep -lE '^\s*([\-\*]|\d\.) ')
if [ -n "$list" ]; then
echo
echo "ERROR: The following pages appear to contain bulleted lists that weren't properly converted."
echo "Make sure all bulleted lists have a blank line before them."
echo
echo "$list"
exit 1
fi
set -e
# Commit new version.
git add -A .
git commit -m "publish site `date`"
echo
echo
echo "A commit was automatically created."
echo
echo "Please sanity-check the output: git diff HEAD~"
echo
echo "When you're ready to publish, create a pull request."
popd >/dev/null