- Shell 74.1%
- Ruby 9.9%
- Dockerfile 8.7%
- HTML 7.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
redmine_agile_live_refresh makes an open board check every 10 s whether an issue in its project changed, and reload if so, so card moves by agents and commits show without F5. It holds off while you drag, type, search or have unapplied Filters/Options changes. Agile Light's own websocket updates skip API changes and commit keywords, hence polling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9k72dETwaeGcdTo6wdgrz |
||
| .forgejo/workflows | ||
| bin | ||
| images | ||
| redmine/plugins | ||
| staging | ||
| README.md | ||
ci-templates
Shared Forgejo Actions workflows for spinach-dev projects, plus the tooling for putting a project on staging.
This repo (and the spinach-dev org) must stay public. Forgejo only lets other repos use workflows from a public repo; if it is private, every project's CI fails with "repo does not exist". It holds no secrets.
| Workflow | Use |
|---|---|
.forgejo/workflows/build-test.yml |
Build/test only, no secrets. Call it from a project's pull-request workflow. |
.forgejo/workflows/build-test-stage.yml |
Build/test, then deploy to staging on tatsoi. Call it on pushes to the default branch. |
.forgejo/workflows/android-apk.yml |
Build a debug APK for Obtainium: as a pre-release, or attached to a promoted release. See "Android apps" below. |
bin/phone-install |
Not a workflow: builds a project's APK and installs it on the phone over adb. See "Android apps" below. |
bin/apk-autoinstall |
Not a workflow: a service on tatsoi that installs each new staging APK, and each promoted release's prod APK, on the phone as soon as CI publishes it. See "Android apps" below. |
bin/runner-recreate |
Not a workflow: recreates the tatsoi runner container on a new runner image. See "Upgrading the runner" below. |
Production (spinach) is never deployed by CI. Production deploys are run by hand, and no workflow holds credentials for spinach.
How staging works
Staging is tatsoi, at https://<project>.staging.heimerman.org (wildcard DNS
already points there). Each project runs as the staging user, with its own
PM2 process, Postgres database and Apache site.
- A push to the default branch runs the project's
stage.yml, which callsbuild-test-stage.yml. - If the build passes, the job SSHes to
staging@tatsoiusing theSTAGING_DEPLOY_KEYsecret. - That key can only run
~staging/bin/ci-staging-dispatch.sh(a forced command in~staging/.ssh/authorized_keys), which runs~staging/work/<project>/deployment/deploy.sh <commit>and nothing else.
A copy of the dispatcher is in staging/ci-staging-dispatch.sh, for
rebuilding tatsoi. Its authorized_keys line is:
command="/home/staging/bin/ci-staging-dispatch.sh",restrict ssh-ed25519 AAAA... ci-staging (Forgejo Actions -> staging@tatsoi)
Adding a project to staging
In the project repo:
deployment/deploy.shmust accept a commit as its first argument and deploy it: fetch, check it out, install, build, restart its PM2 app. It runs asstagingfrom the clone, so take paths and ports from the repo's own.envor relative to the script, not hard-coded home directories.- Copy
staging/templates/stage.ymlandci.ymlinto.forgejo/workflows/, and setproject:and the branch name. - Copy
staging/templates/ci-build.shtodeployment/ci-build.shand fill in the build commands.
In Forgejo (repo settings): make sure Actions is turned on.
On tatsoi, as eric:
stage-add <project> --layout proxy|static-api [--env KEY=VALUE ...]
proxy: the app serves everything (e.g. spinach-game-studio).static-api: Apache serves the built frontend from/var/www/<project>-stagingand forwards/api/*to the app with the prefix removed (e.g. earful).
It picks a free port (from 3010 up), creates the database
<project>_staging, clones the repo, writes a starter .env (database
settings and a random JWT_SECRET), sets up the Apache site and HTTPS
certificate, and runs the first deploy. Re-running it skips whatever already
exists. Use --no-deploy to stop before the first deploy and fill in
app-specific .env settings. Run stage-add with no arguments for all
options.
Example (earful):
stage-add earful --layout static-api \
--env EARFUL_PORT={PORT} --env EARFUL_WEB_ROOT={WEB_ROOT}
stage-add is staging/stage-add.sh, linked into ~/.local/bin on tatsoi.
If the push before stage-add ran shows a failed stage job, that's why:
the dispatcher had no ~staging/work/<project> yet. Re-run the workflow
from the repo's Actions page.
Adding a project to Redmine and CDDash
Staging is only part of it. The rest of a new project's wiring:
- Redmine mirror (tatsoi, as eric):
git clone --mirror ssh://git@git.heimerman.org:2222/spinach-dev/<repo>.git /opt/redmine/repos/<repo>.git.redmine-sync-repos(cron, every 5 minutes) fetches every mirror there. - Redmine project, copied from recoder (modules, trackers, members,
"Closes when"), with the mirror attached as
/repos/<repo>.git: arails runnerscript run by Eric (creating members is blocked for Claude). The identifier is the repo name, lowercased: Redmine refuses capitals. - If the identifier differs from the repo name (capitals, or another
name), two places need to know:
REPO_FOR_PROJECTin~/claude-memory/_bin/issue-dispatcher, so issue sessions get a worktree in~/work/<repo>;"redmineProject": "<identifier>"in the project's CDDashprojects.jsonentry, or CDDash can't close cards on promote.
- Forgejo: repo → Settings → External issue tracker,
https://pm.heimerman.org/issues/{index}, numeric (same as recoder); and Settings → Tags, protectv*for eric. - CDDash (spinach, by Eric): the
projects.jsonentry and the production checkout, as in the project's own deployment docs.
Redmine plugin: all lanes on Agile boards
Agile Light shows only open statuses on a board, and it forgets the lanes
ticked under Options whenever you switch project, so Closed and Rejected
kept disappearing (#43). redmine/plugins/redmine_agile_all_lanes makes
every board start with all status lanes; unticking some under Options still
works for that board until you switch project.
Install or update it on tatsoi (as eric), then restart Redmine:
cp -r redmine/plugins/redmine_agile_all_lanes /opt/redmine/plugins/
cd /opt/redmine && docker compose restart redmine
It patches AgileQuery#options (Agile 1.7.0), so check it still works
after upgrading the Agile plugin.
Redmine plugin: Agile boards refresh themselves
redmine/plugins/redmine_agile_live_refresh makes an open Agile board
reload when an issue in its project changes, so card moves by agents or
commits show up without F5 (#44). The board asks Redmine every 10 seconds
(only while its tab is visible, and straight away when you come back to the
tab) whether anything changed. It waits instead of reloading while you're
dragging a card, typing, searching cards, or have unapplied Filters/Options
changes. Moving a card yourself doesn't cause a reload.
Agile Light's own websocket updates aren't used: they skip API changes
(redmine-issue) and commit keywords, which are most of the card moves.
Install or update it the same way as the all-lanes plugin:
cp -r redmine/plugins/redmine_agile_live_refresh /opt/redmine/plugins/
cd /opt/redmine && docker compose restart redmine
It uses Agile's view_agile_board_bottom hook and its board markup
(Agile 1.7.0), so check it after upgrading the Agile plugin.
One-time Forgejo setup (org-wide)
Once these are done, new repos need nothing in Forgejo except Actions on:
- Read access for staging: a read-only bot user (
staging-bot) in a spinach-dev team with read access to all repos, holding thestaginguser's public key (~staging/.ssh/id_ed25519.pub). Forgejo won't accept a key on a user while it's still a deploy key on a repo, so remove it from each repo's deploy keys first. Without the bot user, add that key as a read-only deploy key on each repo instead. STAGING_DEPLOY_KEYas an organization secret (spinach-dev → Settings → Actions → Secrets), so each repo doesn't need its own copy.
Android apps: staging and prod on the phone
Each Android project that has a staging server builds two apps that install side by side: "" talks to production, " Staging" to staging. They have separate app IDs, so logins, downloads and settings stay apart, and the prod app can never point at staging by accident.
Both apps install themselves. bin/apk-autoinstall runs on tatsoi as the
user service apk-autoinstall (unit in ~/.config/systemd/user/). Every 15 s
it checks the repos listed in ~/.config/apk-autoinstall/repos (one
owner/repo per line) and installs over adb:
- staging: a new
apk-staging-Npre-release, a few seconds after CI publishes it; - prod: a new promoted
vX.Y.Zrelease, onceapk-release.ymlhas attached its APK (a few minutes after Promote in CDDash), so the prod app doesn't fall behind the prod server.
If the phone can't be reached it logs "pending" once, retries every 2 minutes,
and Obtainium still works. It reads releases with
~/.config/forgejo/read-token and keeps the last installed build per repo
(installed for staging, prod = release id) in
~/.local/state/apk-autoinstall.json. It runs on the host rather than in CI so
no CI job ever has adb access to the phone. Logs:
journalctl --user -u apk-autoinstall. To add a project, add its line to the
repos file (the first check only records the current builds; installs start
with the next ones).
Installing by hand: adb first, Obtainium as the fallback. bin/phone-install (put
it on PATH: ln -s "$PWD/bin/phone-install" ~/.local/bin/) builds and installs
over adb from anywhere in a project:
phone-install staging # after the push has deployed to staging
phone-install prod # after promoting; run from the vX.Y.Z tag
phone-install staging core # projects with more than one app name it
It finds the phone over USB, or else over the VPN at 10.8.0.20:5555
(override with PHONE_ADDR), trying once only: repeated connects dismiss the
phone's approval prompt. If it can't reach the phone it says so; use the
CI-built APK in Obtainium then. For prod it warns when HEAD isn't the latest
v* tag, since the prod app should match what the prod server runs.
In the project
-
Two Gradle flavors in
android/app/build.gradle(see earful's):flavorDimensions = ["server"] productFlavors { prod { dimension "server" } staging { dimension "server"; applicationIdSuffix ".staging" } }prodkeeps the existing app ID, so copies already on the phone update in place. Staging resources go inandroid/app/src/staging/res/values/:strings.xmloverridingapp_name,title_activity_main,package_nameandcustom_url_scheme(add.staging/ " Staging"), andic_launcher_background.xmlwith an orange#F57C00, so the icon looks different. -
deployment/build-apk.sh [prod|staging] [app], the only per-project piece: builds the web bundle with that target's server address (whatever the project's build-time variable is), runsnpx cap sync android, then./gradlew assembleProdDebugorassembleStagingDebug. Both flavors share one Capacitor web bundle, so build them one at a time. -
CI workflows (the Obtainium fallback):
- in
stage.yml, a job that builds the staging app on every push to master, running alongside the staging jobs (noneeds:) so it isn't waiting on them; apk-autoinstall puts it on the phone; apk-release.yml, which builds the prod app when av*release is published (CDDash's promote) and attaches it to that release;apk.yml, a "Run workflow" button for a prod pre-release on demand.
See earful's
.forgejo/workflows/for all three. - in
Projects without a staging server keep a single app and just the button.
How the CI side works
android-apk.yml runs on the runner label android, an image built on tatsoi
from images/android/Dockerfile (Node 25, JDK 21, Android SDK 36):
sudo docker build -t spinach-ci/android:36 images/android
The label is in the runner's /data/.runner (android:docker://spinach-ci/android:36).
By default each run publishes a pre-release tagged <tag-prefix>-<run number>
(apk-12, apk-staging-7) with the APK attached, and deletes all but the
newest 5 with that same prefix. CDDash ignores pre-releases, so these never
reach production. With attach-to-release: true (called from an on: release
workflow) it attaches the APK to that release instead.
The APK is signed with the org secret ANDROID_DEV_KEYSTORE (base64 of the
same debug keystore arugula and tatsoi use), so Obtainium installs and
adb install builds update each other in place. versionCode is deliberately
not raised: a higher one would make later adb builds fail as downgrades.
On the phone: Obtainium → add app → the repo URL, source Forgejo (Gitea), pre-releases on, version detection off. One entry per app, each with "Filter release titles by regular expression" set, or the prod entry will grab the newest staging pre-release and fail with "package id does not match":
- prod:
^(apk-\d+|v\d.*)$(button builds and promoted releases) - staging:
^apk-staging-\d+$
The APK filter doesn't work for this: it runs after Obtainium has picked a
release. Right after a promote, the new v… release has no APK for a few
minutes, so a check then may show a "no APK" error until CI attaches it.
Private repos also need a Forgejo access token there.
Runner caches and images
The tatsoi runner (forgejo-runner container, config in its /data) runs
2 jobs at a time (runner.capacity in /data/config.yml), so a project's
APK build can run alongside its staging jobs or another repo's CI.
Shared caches. Every job container gets these Docker volumes, set in
container.options (and allowed in container.valid_volumes) in
/data/config.yml:
ci-gradleat/root/.gradle: the Gradle distribution and downloaded dependencies. Measured 2026-10-13 on earful's staging APK: Gradle took 313 s with nothing cached, 88 s with the cache (both with tatsoi busy).ci-pnpm-storeat/pnpm-store, used through the runner envpnpm_config_store_dir(pnpm 11 ignoresnpm_config_*):pnpm install26 s → 18 s.ci-sccacheat/sccache: sccache's compile cache, used by therustimage (RUSTC_WRAPPER=sccache). It covers C code built by crates too, such as vendored OpenSSL. movies'ci-build.sh: 314 s empty, 96 s warm. Capped at 10 GB (SCCACHE_CACHE_SIZEin the image).ci-cargo-registryat/usr/local/cargo/registry: downloaded crates.
The same options give job containers --cpu-shares=4096 (4× the Docker
default), so when CI and other containers on tatsoi (e.g. an agent
reproducing a build with docker run) want the CPU at once, CI gets most of
it. Against processes outside Docker (Claude sessions, herdr) the kernel
already splits the CPU evenly between system.slice and user.slice.
Reproducing a CI build on tatsoi with the same image and caches:
docker run --rm -v <copy of the repo>:/src -w /src -v ci-sccache:/sccache \
-v ci-cargo-registry:/usr/local/cargo/registry spinach-ci/rust:1 ./deployment/ci-build.sh
Use a copy, not the checkout: files the container writes belong to root.
Every spinach-dev repo shares these caches. Gradle and pnpm lock them, so two
jobs at once are safe. To start over: docker volume rm ci-gradle ci-pnpm-store ci-sccache ci-cargo-registry while no job is running (they're recreated empty).
Images (built by hand on tatsoi, labels in the runner's /data/.runner):
| Label | Image | Built from |
|---|---|---|
docker, ubuntu-latest |
spinach-ci/node:25 |
images/node/Dockerfile (Node 25 + pnpm) |
android |
spinach-ci/android:36 |
images/android/Dockerfile |
rust |
spinach-ci/rust:1 |
images/rust/Dockerfile (Rust + clippy + sccache, and node for checkout) |
A project picks a label with runs-on-label: in its workflow (see movies'
ci.yml). Images other than the node one need node copied in, or
actions/checkout fails within seconds.
docker build -t spinach-ci/node:25 images/node
docker build -t spinach-ci/rust:1 images/rust
After changing /data/config.yml or /data/.runner, wait until no
FORGEJO-ACTIONS-* container is running, then docker restart forgejo-runner.
Upgrading the runner
The runner is the forgejo-runner container, image
code.forgejo.org/forgejo/runner:13 (v13; it was v6.4 until 2026-10). It
isn't in a compose file: bin/runner-recreate <tag> holds the full
docker run command. It waits for running jobs, backs up config.yml and
.runner, keeps the old container as forgejo-runner-old for rollback (the
command is at the top of the script), and starts the new one. Registration
and labels carry over in the forgejo_runner_data volume.
Before a major version, read its release notes for breaking changes, and check every project's workflows against the new version:
docker run --rm -v <dir with the .yml files>:/w:ro code.forgejo.org/forgejo/runner:<tag> \
forgejo-runner validate --workflow --path /w/<file>.yml
Things that stop working from v13 on (none of our workflows use them as of
2026-10-19): the ::set-output, ::set-env and ::add-path commands (write
to $FORGEJO_OUTPUT, $FORGEJO_ENV, $FORGEJO_PATH instead), registry
login through DOCKER_USERNAME/DOCKER_PASSWORD secrets, the
container.network_mode config key, and expressions or matrix excludes that
used to only log a warning now fail the job. v13 needs Docker 25 or newer.
Removing a project from staging
sudo -u staging pm2 delete <app> && sudo -u staging pm2 save
sudo a2dissite <project>.staging.heimerman.org <project>.staging.heimerman.org-le-ssl
sudo systemctl reload apache2
sudo certbot delete --cert-name <project>.staging.heimerman.org
sudo -u postgres psql -c 'DROP DATABASE "<project>_staging"' -c 'DROP ROLE "<project>_staging"'
sudo rm -rf ~staging/work/<project> /var/www/<project>-staging