on edd1d21 help sign in
haskell.nix/scripts/update-docs.nix
52 lines 1.6 kB history raw
1{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs
2, python3, generatedOptions }:
4with stdenv.lib;
6let
7 repo = "git@github.com:input-output-hk/haskell.nix.git";
8 sshKey = "/run/keys/buildkite-haskell-dot-nix-ssh-private";
9 # Doesn't work with Python 2 in 20.03, fixed in master in https://github.com/NixOS/nixpkgs/commit/ee17a6a8379ffd791309b13143d76431f2f671df
10 py3mkdocs = mkdocs.override { python = python3; };
11in
12 # update-docs depends on glibc which doesn't build on darwin
13 meta.addMetaAttrs { platforms = platforms.linux; } (writeScript "update-docs.sh" ''
14 #!${stdenv.shell}
16 set -euo pipefail
18 export PATH="${makeBinPath [ coreutils glibc git openssh gnused py3mkdocs ]}"
20 source ${./git.env}
22 rev=$(git rev-parse --short HEAD)
23 cd $(git rev-parse --show-toplevel)
25 echo "Preprocessing..."
26 cat docs/reference/modules-preamble.md ${generatedOptions} |
27 sed -e "s,$PWD/\?,," > docs/reference/modules.md
29 echo "Building..."
30 rm -rf site
31 mkdocs build
32 touch site/.nojekyll
33 sed -i -e '/Build Date/d' site/index.html
34 sed -i -e '/lastmod/d' site/sitemap.xml
35 rm -f site/sitemap.xml.gz
36 rm docs/reference/modules.md
38 echo "Updating git index..."
39 git fetch origin
40 git checkout gh-pages
41 git reset --hard origin/gh-pages
42 GIT_WORK_TREE=$(pwd)/site git add -A
43 check_staged
44 echo "Committing changes..."
45 git commit --no-gpg-sign --message "Update gh-pages for $rev"
47 use_ssh_key ${sshKey}
49 if [ "''${BUILDKITE_BRANCH:-}" = master ]; then
50 git push ${repo} HEAD:gh-pages
51 fi
52 '')