From 59349dfe93c4bca11c125c107d7dad9756f1e7b6 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 10 May 2026 21:55:41 +0200 Subject: [PATCH] feat(ci): add nightly staging deploy workflow Runs daily at 02:00 (and on workflow_dispatch). Builds the prod compose stack with BuildKit, writes a transient .env.staging from Gitea secrets, then `docker compose up -d --wait` so the job fails loudly if any service's healthcheck never reports healthy. The --profile staging flag starts the mailpit catcher in place of a real SMTP relay; no production SMTP credentials touch the staging environment. The .env.staging file is cleaned up in `if: always()` to avoid leaving secrets in the runner workspace between runs. Refs #497. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/nightly.yml | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .gitea/workflows/nightly.yml diff --git a/.gitea/workflows/nightly.yml b/.gitea/workflows/nightly.yml new file mode 100644 index 00000000..82fc0c5c --- /dev/null +++ b/.gitea/workflows/nightly.yml @@ -0,0 +1,80 @@ +name: nightly + +# Builds and deploys the staging environment from main every night. +# Runs on the self-hosted runner using Docker-out-of-Docker (the docker +# socket is mounted in), so `docker compose build` produces images on +# the host daemon and `docker compose up` consumes them directly — no +# registry hop. +# +# Staging environment isolation: +# - project name: archiv-staging +# - host ports: backend 8081, frontend 3001 +# - profile: staging (starts mailpit instead of a real SMTP relay) +# +# Required Gitea secrets: +# STAGING_POSTGRES_PASSWORD +# STAGING_MINIO_PASSWORD +# STAGING_MINIO_APP_PASSWORD +# STAGING_OCR_TRAINING_TOKEN +# STAGING_APP_ADMIN_USERNAME +# STAGING_APP_ADMIN_PASSWORD + +on: + schedule: + - cron: "0 2 * * *" + workflow_dispatch: + +env: + # Ensures the backend Dockerfile's `RUN --mount=type=cache` lines are + # honoured (Maven cache survives between runs). + DOCKER_BUILDKIT: "1" + +jobs: + deploy-staging: + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + + - name: Write staging env file + run: | + cat > .env.staging <