forked from input-output-hk/haskell.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-docs.nix
49 lines (38 loc) · 1.31 KB
/
update-docs.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ stdenv, lib, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs
, generatedOptions }:
with lib;
let
repo = "[email protected]:input-output-hk/haskell.nix.git";
sshKey = "/run/keys/buildkite-haskell-dot-nix-ssh-private";
in
# update-docs depends on glibc which doesn't build on darwin
meta.addMetaAttrs { platforms = platforms.linux; } (writeScript "update-docs.sh" ''
#!${stdenv.shell}
set -euo pipefail
export PATH="${makeBinPath [ coreutils glibc git openssh gnused mkdocs ]}"
source ${./git.env}
rev=$(git rev-parse --short HEAD)
cd $(git rev-parse --show-toplevel)
echo "Preprocessing..."
cat ${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
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
'')