on 2a03328 help sign in
haskell.nix/scripts/update-docs.nix
50 lines 1.4 kB history raw
1{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs
2, 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";
9in
10 # update-docs depends on glibc which doesn't build on darwin
11 meta.addMetaAttrs { platforms = platforms.linux; } (writeScript "update-docs.sh" ''
12 #!${stdenv.shell}
14 set -euo pipefail
16 export PATH="${makeBinPath [ coreutils glibc git openssh gnused mkdocs ]}"
18 source ${./git.env}
20 rev=$(git rev-parse --short HEAD)
21 cd $(git rev-parse --show-toplevel)
23 echo "Preprocessing..."
24 cat docs/reference/modules-preamble.md ${generatedOptions} |
25 sed -e "s,$PWD/\?,," > docs/reference/modules.md
27 echo "Building..."
28 rm -rf site
29 mkdocs build
30 touch site/.nojekyll
31 sed -i -e '/Build Date/d' site/index.html
32 sed -i -e '/lastmod/d' site/sitemap.xml
33 rm -f site/sitemap.xml.gz
34 rm docs/reference/modules.md
36 echo "Updating git index..."
37 git fetch origin
38 git checkout gh-pages
39 git reset --hard origin/gh-pages
40 GIT_WORK_TREE=$(pwd)/site git add -A
41 check_staged
42 echo "Committing changes..."
43 git commit --no-gpg-sign --message "Update gh-pages for $rev"
45 use_ssh_key ${sshKey}
47 if [ "''${BUILDKITE_BRANCH:-}" = master ]; then
48 git push ${repo} HEAD:gh-pages
49 fi
50 '')