vitess.io: Change publish-site.sh to create the new website pages in the docs/ directory.

This greatly simplifies the process compared to the old process where we
had to switch branches (master => gh-pages) in between and move files
around.
This commit is contained in:
Michael Berlin 2016-11-05 20:38:46 -07:00
Родитель 038782900b
Коммит f08cb2f52a
1 изменённых файлов: 31 добавлений и 30 удалений

Просмотреть файл

@ -2,41 +2,37 @@
set -e
git checkout gh-pages
# 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).
git rm --ignore-unmatch -rf *
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
git checkout master doc
git checkout master README.md
git checkout master index.md
git checkout master vitess.io
# 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 --name=vitess_publish_site -v $PWD/vitess.io:/in vitess/publish-site bash -c \
'cp -R /in /out && cd /out && bundle install && bundle exec jekyll build'
docker cp vitess_publish_site:/out/. vitess.io/
# There are cases where docker cp copies the contents of "out" in a
# subdirectory "out" on the destination. If that happens, move/overwrite
# everything up by one directory level.
if [ -d vitess.io/out/ ]; then
cp -a vitess.io/out/* vitess.io/
fi
docker rm vitess_publish_site
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)
(cd vitess.io && bundle install && bundle exec jekyll build --destination ../$website_dir)
fi
# clean up
rm -rf doc
rm -rf README.md
git add vitess.io/_site/*
git mv vitess.io/_site/* .
git add vitess.io/LICENSE
git mv vitess.io/LICENSE .
rm -rf vitess.io
# Change to docs/ directory.
pushd $website_dir >/dev/null
# pre-commit checks
set +e
@ -51,11 +47,16 @@ if [ -n "$list" ]; then
fi
set -e
git add -u
# 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: git push origin gh-pages"
echo "When you're ready to publish, create a pull request."
popd >/dev/null