on 2e49d28 help sign in
haskell.nix/scripts/update-docs.nix
46 lines 1.2 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 writeScript "update-docs.sh" ''
11 #!${stdenv.shell}
13 set -euo pipefail
15 export PATH="${makeBinPath [ coreutils glibc git openssh gnused mkdocs ]}"
17 source ${./git.env}
19 echo "Preprocessing..."
20 cat docs/reference/modules-preamble.md ${generatedOptions} > docs/reference/modules.md
22 echo "Building..."
23 rm -rf site
24 mkdocs build
25 touch site/.nojekyll
26 sed -i -e '/Build Date/d' site/index.html
27 sed -i -e '/lastmod/d' site/sitemap.xml
28 rm -f site/sitemap.xml.gz
29 rev=$(git rev-parse --short HEAD)
30 rm docs/reference/modules.md
32 echo "Updating git index..."
33 git fetch origin
34 git checkout gh-pages
35 git reset --hard origin/gh-pages
36 GIT_WORK_TREE=$(pwd)/site git add -A
37 check_staged
38 echo "Committing changes..."
39 git commit --no-gpg-sign --message "Update gh-pages for $rev"
41 use_ssh_key ${sshKey}
43 if [ "''${BUILDKITE_BRANCH:-}" = master ]; then
44 git push ${repo} HEAD:gh-pages
45 fi
46 ''