Files
jaredandClaude Opus 5.5 379570bbdc CI modelled on Pulse, deploy script with rollback, bootstrap, README
- .gitea/workflows/ci.yml: flake8 + dash check, pytest (90% coverage floor), MariaDB
  integration tests, bandit, pip-audit, gitleaks, actionlint, shellcheck, zizmor, semgrep;
  main deploys through a signed webhook and waits for /health to report the commit.
- deploy/thor_deploy.sh: deploys an exact sha, installs units and nginx site when changed,
  rolls back unless /health reports the sha with a working database. Sandbox-tested.
- deploy/bootstrap.sh: idempotent first install on CT 173.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:35:28 -05:00

26 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Installs and starts a throwaway MariaDB inside a CI job container (as root) and creates
# the database and user from DB_NAME, DB_USER and DB_PASSWORD. Same approach as Pulse's
# scripts/ci/mariadb.sh: the Gitea runner can't reach service containers by name.
set -euo pipefail
: "${DB_NAME:?}" "${DB_USER:?}" "${DB_PASSWORD:?}"
for attempt in 1 2 3; do
if apt-get -o Acquire::Retries=3 update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 install -y -qq --no-install-recommends \
mariadb-server >/dev/null; then
break
fi
[ "$attempt" = 3 ] && { echo "::error::could not install mariadb-server"; exit 1; }
echo "apt failed (attempt $attempt); retrying in 10s"
sleep 10
done
mkdir -p /run/mysqld && chown mysql:mysql /run/mysqld
if ! mariadb-admin ping --silent 2>/dev/null; then
(mariadbd --user=mysql --bind-address=127.0.0.1 --port=3306 >/tmp/mariadb.log 2>&1 &)
fi
for _ in $(seq 1 30); do mariadb-admin ping --silent 2>/dev/null && break; sleep 1; done
mariadb -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`;
CREATE USER IF NOT EXISTS '${DB_USER}'@'127.0.0.1' IDENTIFIED BY '${DB_PASSWORD}';
GRANT ALL ON \`${DB_NAME}\`.* TO '${DB_USER}'@'127.0.0.1';"
mariadb --version