juniper/docs/book/ci-build.sh
Christian Legnitto b96879e2db Add a git ssh origin when pushing docs
Azure apparently downloads the source via http,
so when we go to push the ssh keychain is not used.
adding origin shoudl fix it, as was done in
https://cloudblogs.microsoft.com/opensource/2019/04/05/publishing-github-pages-from-azure-pipelines/
2019-04-16 21:52:58 -07:00

52 lines
1.3 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 remote set-url --push origin git@github.com:graphql-rust/juniper.git
git config --local user.name "Juniper 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