Files
pplus-web/.gitea/workflows/deploy.yml
T
alexm eb77cf6902
Build, test, deploy / site (push) Successful in 6m43s
Publish to the directory the site is served from
The deploy job's directory under /srv/www defaulted to the repository's
name. This repository is pplus-web and the site is served from
/srv/www/pplus, so the first job that passed here published to
/srv/www/pplus-web and the live site stayed as it was. The default is
pplus; SITE_SLUG still overrides it.
2026-11-13 06:26:50 -05:00

114 lines
5.7 KiB
YAML

# Programming+ on Gitea Actions. The runner's label `quarto-deploy` names a container image (Node, git, rsync, curl,
# Quarto, pixi) with the droplet's /srv/www bound in, and every job gets a new container: nothing is kept between
# jobs, and everything else the job needs comes from pixi.lock. docs/deploy.md says what the job needs of a runner.
#
# Every push and pull request runs `pixi run ci` in the environment pixi.lock pins (Node, Python, pandoc, Mojo):
# every test of the site (the Quarto ones fail, not skip, without pandoc), and core's mojo-status-strict at the
# pinned commit. The job is kept light on purpose: the runner is a server with other work. Core's own tests and
# everything that builds Mojo are core's gate, which runs on another runner (core's docs/ci.md); a developer runs
# `pixi run core-test` before moving the pointer. A push to main also checks the chain of pointers
# (`pixi run release-check`) and publishes the site to /srv/www/<slug> as an atomic release (scripts/deploy.sh).
#
# On GitHub Actions the build and test steps run with one change, `runs-on: ubuntu-latest`; the publish step needs
# a host that serves /srv/www, so it is the droplet's.
#
# Repository -> Settings -> Actions -> Variables (all optional):
# SITE_SLUG the directory under /srv/www (defaults to pplus, the directory docs/Caddyfile serves)
# SITE_URL e.g. https://pplus.scient.ing, turns on the smoke test
name: Build, test, deploy
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
env:
# set by Gitea and GitHub Actions already; written here so the tests' "fail, not skip, under CI" never depends on it
CI: "true"
# the pixi that reads pixi.lock; when the runner has another version, this one is fetched into the cache below
PIXI_VERSION: "0.83.0"
jobs:
site:
# a pull request runs only from a branch of this repository: a fork's workflow would run its own code in a
# container that can write the droplet's web root (docs/deploy.md). Drop this line for a runner that cannot.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
# The label from the runner registration: on this runner a container image, new for every job.
runs-on: quarto-deploy
timeout-minutes: 60
steps:
# core/ is pplus-core, a submodule pinned to one commit, and core/library/ is pplus-library, pinned by core;
# the job's token must be able to read both repositories while they are private
- uses: actions/checkout@v4
with:
submodules: recursive
# pixi: the image's when it is the pinned version, else the pinned release, fetched into a cache directory
# (which lasts only where the runner keeps a home between jobs) and checked by SHA-256
- name: pixi, pinned
shell: bash
run: |
set -euo pipefail
if command -v pixi >/dev/null && [ "$(pixi --version | cut -d' ' -f2)" = "$PIXI_VERSION" ]; then
echo "pixi $PIXI_VERSION is on the PATH: $(command -v pixi)"; exit 0
fi
dir="${PPLUS_CI_CACHE:-$HOME/.cache/pplus-ci}/pixi-$PIXI_VERSION"
if [ ! -x "$dir/pixi" ]; then
case "$(uname -s)-$(uname -m)" in
Linux-x86_64) asset=pixi-x86_64-unknown-linux-musl.tar.gz; sum=064f371e692aaa3400ac581c89da2843c91437f20c2d9155395a5d0037f33551 ;;
Linux-aarch64) asset=pixi-aarch64-unknown-linux-musl.tar.gz; sum=d08403d8f048626ec93ba7b7c56e3b747a5f3a95c4e6e0c815ceb264f5f0b9ce ;;
*) echo "no pinned pixi for $(uname -sm)" >&2; exit 1 ;;
esac
tmp="$(mktemp -d)"
curl -fsSL --retry 3 -o "$tmp/$asset" "https://github.com/prefix-dev/pixi/releases/download/v$PIXI_VERSION/$asset"
echo "$sum $tmp/$asset" | sha256sum -c -
mkdir -p "$dir" && tar -xzf "$tmp/$asset" -C "$dir" pixi && rm -rf "$tmp"
fi
echo "$dir" >> "$GITHUB_PATH"
"$dir/pixi" --version
- name: The pinned environment, exactly as pixi.lock has it
run: pixi install --locked
# every test of the site, and core's mojo-status-strict at the pinned commit (pixi.toml)
- name: pixi run ci
run: pixi run ci
# each pointer on its pushed branch, the generated files current, Mojo pinned alike (scripts/release.mjs);
# a pointer it cannot check (a private remote the job cannot ask) is reported, not failed
- name: The chain of pointers
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: pixi run release-check
- name: Assemble the site
run: scripts/assemble.sh
env:
GITHUB_SHA: ${{ github.sha }}
- name: Publish to /srv/www
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
env:
# not the repository's name: the site is served from /srv/www/pplus, and a job that published to
# /srv/www/pplus-web succeeded while the live site stayed as it was
SLUG: ${{ vars.SITE_SLUG || 'pplus' }}
GITHUB_SHA: ${{ github.sha }}
run: scripts/deploy.sh "$SLUG"
- name: Smoke test
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.SITE_URL != ''
shell: bash
env:
SITE_URL: ${{ vars.SITE_URL }}
GITHUB_SHA: ${{ github.sha }}
run: |
sleep 2
live=$(curl -fsS "$SITE_URL/VERSION")
case "$live" in
"${GITHUB_SHA:0:12}"*) echo "live site is at $live" ;;
*) echo "live site reports '$live', expected ${GITHUB_SHA:0:12}" >&2; exit 1 ;;
esac