on iko/ghcjs-patch-master help sign in
Automatically update gh-pages branch when docs change (#159)
8e141afRodney Lorrimar
.buildkite/pipeline.yml+8
@@ -3,3 +3,11 @@ steps:
3 command: "./test/tests.sh"
3 command: "./test/tests.sh"
4 agents:
4 agents:
5 system: x86_64-linux
5 system: x86_64-linux
6+
7+ - label: 'Update docs'
8+ command:
9+ - nix-build -A maintainer-scripts.update-docs -o update-docs.sh
10+ - ./update-docs.sh
11+ branches: master
12+ agents:
13+ system: x86_64-linux
default.nix+1
@@ -137,6 +137,7 @@ let
137 update-hackage = self.callPackage ./scripts/update-hackage.nix {};
137 update-hackage = self.callPackage ./scripts/update-hackage.nix {};
138 update-stackage = self.callPackage ./scripts/update-stackage.nix {};
138 update-stackage = self.callPackage ./scripts/update-stackage.nix {};
139 update-pins = self.callPackage ./scripts/update-pins.nix {};
139 update-pins = self.callPackage ./scripts/update-pins.nix {};
140+ update-docs = self.callPackage ./scripts/update-docs.nix {};
140 };
141 };
141
142
142 # Make this handy overridable fetch function available.
143 # Make this handy overridable fetch function available.
scripts/update-docs.nixnew file+39
@@ -0,0 +1,39 @@
1+{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs }:
2+
3+with stdenv.lib;
4+
5+let
6+ repo = "git@github.com:input-output-hk/haskell.nix.git";
7+ sshKey = "/run/keys/buildkite-haskell-dot-nix-ssh-private";
8+in
9+ writeScript "update-docs.sh" ''
10+ #!${stdenv.shell}
11+
12+ set -euo pipefail
13+
14+ export PATH="${makeBinPath [ coreutils glibc git openssh gnused mkdocs ]}"
15+
16+ source ${./git.env}
17+
18+ echo "Building..."
19+ rm -rf site
20+ mkdocs build
21+ touch site/.nojekyll
22+ sed -i -e '/Build Date/d' site/index.html
23+ sed -i -e '/lastmod/d' site/sitemap.xml
24+ rm -f site/sitemap.xml.gz
25+ rev=$(git rev-parse --short HEAD)
26+
27+ echo "Updating git index..."
28+ git checkout gh-pages
29+ GIT_WORK_TREE=$(pwd)/site git add -A
30+ check_staged
31+ echo "Committing changes..."
32+ git commit --no-gpg-sign --message "Update gh-pages for $rev"
33+
34+ use_ssh_key ${sshKey}
35+
36+ if [ "''${BUILDKITE_BRANCH:-}" = master ]; then
37+ git push ${repo} HEAD:gh-pages
38+ fi
39+ ''