Files
stpweb/.gitea/workflows/maintenance.yaml
adamfandClaude Opus 5.5 79a9011212
Test and deploy / test (push) Successful in 11m8s
Test and deploy / deploy (push) Successful in 8m25s
Weekly Maintenance / maintenance (push) Successful in 46s
Fix the tunnel's error 1000 and notes sync, move maintenance to 05:00
nginx's network aliases for the public names vanish while it is stopped,
so cloudflared fell through to public DNS, got Cloudflare's own IPs and
visitors saw error 1000 on every deploy. nginx now has a fixed address and
cloudflared pins both names to it, so a stopped nginx is a plain 502.

The same aliases sent silverbullet-git's pushes to ssh://DOMAIN:2222 to
nginx, which has no 2222: nothing has pushed since 2026-10-15. It now maps
DOMAIN to the host gateway, where gitea publishes that port.

The weekly maintenance restarts dockerd and every container; at 01:00 it
kept catching late-night SilverBullet saves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 01:17:31 +00:00

65 lines
2.5 KiB
YAML

name: Weekly Maintenance
on:
schedule:
# 05:00 UTC Sunday (06:00 in BST). The upgrade restarts dockerd and
# every container, so it runs when nobody is likely to be mid-edit;
# 01:00 kept catching late-night SilverBullet saves.
- cron: "0 5 * * 0"
workflow_dispatch:
jobs:
maintenance:
runs-on: self-hosted
steps:
- name: Show disk usage before
run: df -h /
- name: Update apt package index
run: sudo apt-get update
- name: Upgrade system packages
run: sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
- name: Autoremove obsolete packages
run: sudo apt-get -y autoremove --purge
# Both compose steps below take .compose.lock, the same flock
# deploy.yaml holds while it runs compose. Without it this weekly
# job could recreate containers while a deploy is mid-build, and
# two `compose up`s racing over the same project can each recreate
# a container the other just started. flock blocks until the other
# holder finishes, so the job waits rather than fails. The lock is
# taken per step, not across both: nothing needs pull and up to be
# atomic, and holding it for less time keeps a deploy from waiting
# behind a long pull.
- name: Pull latest base images
working-directory: /home/adamf/deploy/web_server
run: flock .compose.lock docker compose pull
- name: Rebuild and restart containers
working-directory: /home/adamf/deploy/web_server
run: flock .compose.lock docker compose up -d --build --remove-orphans
- name: Prune unused Docker images
run: docker image prune -af
- name: Prune old Docker build cache
run: docker builder prune -f --filter until=336h
- name: Show running containers
run: docker compose ps
working-directory: /home/adamf/deploy/web_server
- name: Show disk usage after
run: df -h /
- name: Reboot if required
run: |
if [ -f /var/run/reboot-required ]; then
echo "Reboot required — scheduling in 1 minute"
sudo shutdown -r +1
else
echo "No reboot needed"
fi