94cc621598
Cribbed from https://cloudblogs.microsoft.com/opensource/2019/04/05/publishing-github-pages-from-azure-pipelines/ and https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/install-ssh-key?view=azure-devops
51 lines
1.2 KiB
Bash
Executable file
51 lines
1.2 KiB
Bash
Executable file
#! /usr/bin/env bash
|
|
|
|
# Usage: ./ci-build.sh VERSION
|
|
#
|
|
# This script builds the book to HTML with mdbook
|
|
# commits and pushes the contents to the repo in the "gh-pages" branch.
|
|
#
|
|
# It is only inteded for use on the CI!
|
|
|
|
# Enable strict error checking.
|
|
set -exo pipefail
|
|
|
|
DIR=$(dirname $(readlink -f $0))
|
|
MDBOOK="mdbook"
|
|
|
|
cd $DIR
|
|
|
|
# Verify version argument.
|
|
|
|
if [[ -z "$1" ]]; then
|
|
echo "Missing required argument 'version': cargo make build-book VERSION"
|
|
exit
|
|
fi
|
|
VERSION="$1"
|
|
|
|
# Download mdbook if not found.
|
|
|
|
if [ $MDBOOK -h ]; then
|
|
echo "mdbook found..."
|
|
else
|
|
echo "mdbook not found. Downloading..."
|
|
curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.0/mdbook-v0.2.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
|
|
mv ./mdbook /tmp/mdbook
|
|
MDBOOK="/tmp/mdbook"
|
|
fi
|
|
|
|
$MDBOOK build
|
|
echo $VERSION > ./_rendered/VERSION
|
|
rm -rf /tmp/book-content
|
|
mv ./_rendered /tmp/book-content
|
|
|
|
cd $DIR/../..
|
|
git clean -fd
|
|
git checkout gh-pages
|
|
rm -rf $VERSION
|
|
mv /tmp/book-content ./$VERSION
|
|
git config --local user.name "Juniper Doc Bot"
|
|
git config --local user.email "juniper@example.com"
|
|
git add -A $VERSION
|
|
git commit -m "Updated book for $VERSION ***NO_CI***"
|
|
git push origin gh-pages
|