.gitbay/pages.sh
36 lines · 1414 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
16tmp=$(mktemp -d)
17trap 'rm -rf "$tmp"' EXIT
18site="$tmp/site"
19work="$tmp/work"
20
21cargo run --release --locked -- build docs -o "$site" --strict
22rm -f "$site/.orgo-cache.json"
23
24# An orphan history: the pages branch carries the built site and nothing else, so
25# each publish replaces it wholesale rather than accumulating every past build.
26git init -q "$work"
27cp -R "$site/." "$work/"
28printf '.orgo-cache.json\n' >"$work/.gitignore"
29git -C "$work" add -A
30git -C "$work" -c user.name=gitbay-ci -c user.email=ci@orgo.krz.sh commit -q \
31 -m "Publish the documentation site
32
33Built from ${GITBAY_SHA} by \`orgo build docs -o _site --strict\`."
34git -C "$work" push -q --force "ssh://git@gitbay.org/${GITBAY_REPO}.git" HEAD:refs/heads/pages
35
36echo "published the site from ${GITBAY_SHA} to the pages branch"