haskell.nix/scripts/update-docs.nix
Rodney Lorrimar e15f235319 More documentation (#179)
* docs: Fix notes about .nix-tools.cache

Relates to #57

* docs: Add note about Cabal 2.4 requirement

Fixes #164

* docs: Autogenerate module option reference

* docs: Update library reference

* Buildkite: enable docs build on branches
2019-06-15 07:11:52 +02:00

47 lines
1.2 KiB
Nix

{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs
, generatedOptions }:
with stdenv.lib;
let
repo = "git@github.com:input-output-hk/haskell.nix.git";
sshKey = "/run/keys/buildkite-haskell-dot-nix-ssh-private";
in
writeScript "update-docs.sh" ''
#!${stdenv.shell}
set -euo pipefail
export PATH="${makeBinPath [ coreutils glibc git openssh gnused mkdocs ]}"
source ${./git.env}
echo "Preprocessing..."
cat docs/reference/modules-preamble.md ${generatedOptions} > docs/reference/modules.md
echo "Building..."
rm -rf site
mkdocs build
touch site/.nojekyll
sed -i -e '/Build Date/d' site/index.html
sed -i -e '/lastmod/d' site/sitemap.xml
rm -f site/sitemap.xml.gz
rev=$(git rev-parse --short HEAD)
rm docs/reference/modules.md
echo "Updating git index..."
git fetch origin
git checkout gh-pages
git reset --hard origin/gh-pages
GIT_WORK_TREE=$(pwd)/site git add -A
check_staged
echo "Committing changes..."
git commit --no-gpg-sign --message "Update gh-pages for $rev"
use_ssh_key ${sshKey}
if [ "''${BUILDKITE_BRANCH:-}" = master ]; then
git push ${repo} HEAD:gh-pages
fi
''