68 lines
2.3 KiB
YAML
68 lines
2.3 KiB
YAML
name: Deploy docs
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['*.*.*']
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
SITE_SLUG: coursebank
|
|
CRATE: coursebank
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: pixi-build-rust
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Write the channel switcher
|
|
run: |
|
|
cat > "${{ gitea.workspace }}/docs-banner.html" <<'HTML'
|
|
<div style="padding:.4rem .75rem;font:0.85rem/1.4 sans-serif;border-bottom:1px solid var(--border-color,#ddd);background:var(--sidebar-background-color,#f7f7f7);color:var(--main-color,#000)">
|
|
Docs channel:
|
|
<a id="ch-release" href="#" style="margin:0 .35rem">release</a>|
|
|
<a id="ch-nightly" href="#" style="margin:0 .35rem">nightly</a>
|
|
<script>
|
|
(function () {
|
|
var m = location.pathname.match(/^(.*\/)(release|nightly)\//);
|
|
var base = m ? m[1] : location.pathname.replace(/[^\/]*$/, "");
|
|
document.getElementById("ch-release").href = base + "release/";
|
|
document.getElementById("ch-nightly").href = base + "nightly/";
|
|
if (m) { document.getElementById("ch-" + m[2]).style.fontWeight = "bold"; }
|
|
})();
|
|
</script>
|
|
</div>
|
|
HTML
|
|
|
|
- name: Build the API docs
|
|
env:
|
|
RUSTDOCFLAGS: "--html-before-content ${{ gitea.workspace }}/docs-banner.html"
|
|
run: |
|
|
pixi install --locked
|
|
pixi run doc-build
|
|
|
|
- name: Redirect the channel root to the crate page
|
|
run: |
|
|
printf '%s\n' "<!doctype html><meta http-equiv=\"refresh\" content=\"0; url=${CRATE}/\">" > target/doc/index.html
|
|
|
|
- name: Publish the channel to /srv/www
|
|
run: |
|
|
case "${{ gitea.ref }}" in
|
|
refs/tags/*) channel=release ;;
|
|
*) channel=nightly ;;
|
|
esac
|
|
dest="/srv/www/${SITE_SLUG}/${channel}"
|
|
mkdir -p "$dest"
|
|
rsync -a --delete "target/doc/" "$dest/"
|
|
|
|
- name: Point the site root at the latest release, else nightly
|
|
run: |
|
|
root="/srv/www/${SITE_SLUG}"
|
|
if [ -d "$root/release/${CRATE}" ]; then
|
|
target="release/${CRATE}/"
|
|
else
|
|
target="nightly/${CRATE}/"
|
|
fi
|
|
printf '%s\n' "<!doctype html><meta http-equiv=\"refresh\" content=\"0; url=${target}\">" > "$root/index.html"
|