Initial commit
Build, test, deploy / site (push) Failing after 15m13s

This commit is contained in:
alexm committed 2026-11-12 22:24:02 -05:00
commit e092cb029c
252 files changed
+35037

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
# SPDX-License-Identifier: Apache-2.0
# Publish ./site to /srv/www/<slug> as an atomic release (DEPLOY_ROOT overrides /srv/www).
#
# scripts/deploy.sh <slug> [host]
#
# Without a host, the script runs on the server itself (the Gitea runner lives
# on the droplet). With a host (user@droplet), it rsyncs over SSH. Either way
# the layout on the server is:
#
# /srv/www/<slug> -> symlink to the live release
# /srv/www/<slug>.releases/ one directory per deployed commit, last 5 kept
#
# The symlink swap is one rename, so visitors never see a half-copied site, and
# rolling back is `ln -sfn /srv/www/<slug>.releases/<sha> /srv/www/<slug>`.
set -euo pipefail
slug="${1:?usage: deploy.sh <slug> [user@host]}"
host="${2:-}"
sha="${GITHUB_SHA:-$(git rev-parse HEAD 2>/dev/null || date +%s)}"
root="${DEPLOY_ROOT:-/srv/www}"
releases="$root/$slug.releases"
release="$releases/${sha:0:12}"
live="$root/$slug"
[ -f site/index.html ] || { echo "site/ is missing; run scripts/assemble.sh first" >&2; exit 1; }
# Everything that touches the server, as one script, so the SSH path and the local path stay identical.
remote_script=$(cat <<EOS
set -euo pipefail
mkdir -p "$releases"
rm -rf "$release.tmp"
mv "$release.incoming" "$release.tmp"
# a rebuilt commit replaces its earlier release
rm -rf "$release"
mv "$release.tmp" "$release"
# a plain directory from before releases existed is kept aside, once
if [ -d "$live" ] && [ ! -L "$live" ]; then mv "$live" "$releases/before-releases"; fi
# swap in one rename
ln -sfn "$release" "$live.next"
mv -Tf "$live.next" "$live"
# keep the five newest releases
ls -1dt "$releases"/*/ 2>/dev/null | tail -n +6 | xargs -r rm -rf
echo "live: $live -> \$(readlink "$live")"
EOS
)
if [ -z "$host" ]; then
mkdir -p "$releases"
rm -rf "$release.incoming"
if command -v rsync >/dev/null; then rsync -a --delete site/ "$release.incoming/"; else cp -a site "$release.incoming"; fi
bash -c "$remote_script"
else
ssh -o BatchMode=yes "$host" "mkdir -p '$releases'"
rsync -a --delete -e "ssh -o BatchMode=yes" site/ "$host:$release.incoming/"
ssh -o BatchMode=yes "$host" "$remote_script"
fi