.gitbay/pages.sh
38 lines · 1421 bytes · executable
1#!/bin/sh
2# Publish the documentation site to the `pages` branch, which gitbay serves at
3# https://orgo.krz.sh. Queued on every branch push; does nothing off main.
4#
5# The site is fifteen org files built by the tool that documents them, so this is
6# also the most honest smoke test in the repository: if orgo cannot build its own
7# documentation, the job fails and says so. --strict makes a broken internal link
8# a failure, because docs rot by having their links quietly stop resolving.
9set -eu
10
11if [ "${GITBAY_REF:-}" != "main" ]; then
12 echo "ref is ${GITBAY_REF:-unset}, not main — nothing to publish"
13 exit 0
14fi
15
16. .gitbay/bot-ssh.sh
17
18tmp=$(mktemp -d)
19trap 'rm -rf "$tmp"' EXIT
20site="$tmp/site"
21work="$tmp/work"
22
23cargo run --locked -- build docs -o "$site" --strict
24rm -f "$site/.orgo-cache.json"
25
26# An orphan history: the pages branch carries the built site and nothing else, so
27# each publish replaces it wholesale rather than accumulating every past build.
28git init -q "$work"
29cp -R "$site/." "$work/"
30printf '.orgo-cache.json\n' >"$work/.gitignore"
31git -C "$work" add -A
32git -C "$work" -c user.name=gitbay-ci -c user.email=ci@orgo.krz.sh commit -q \
33 -m "Publish the documentation site
34
35Built from ${GITBAY_SHA} by \`orgo build docs -o _site --strict\`."
36git -C "$work" push -q --force "ssh://$GITBAY_SSH/$GITBAY_REPO.git" HEAD:refs/heads/pages
37
38echo "published the site from ${GITBAY_SHA} to the pages branch"