From 13e22a9c7d81defc09c85745aff219e19a8a2253 Mon Sep 17 00:00:00 2001 From: feco Date: Sun, 22 Nov 2026 11:48:57 +0000 Subject: [PATCH] CI: main runs the tests only; images are built for prod The runner takes one job at a time, so a deployment (push to main, then to prod) built every image twice and the two runs took turns. Now main only tests, and prod tests, builds and deploys. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL --- .gitea/workflows/ci.yml | 12 +++++++----- deploy/README.md | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6088acd..531f18c 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,9 +1,10 @@ -# main: tests and image build (tags: commit hash, `main`). -# prod: the same, then deployment to the server (tags: commit hash, `prod`, `latest`). +# main: tests only. +# prod: tests, image build (tags: commit hash, `prod`, `latest`), then +# deployment to the server. # -# Runs on the self-hosted runner in ci/runner (label `linux`). Jobs use the -# host's Docker daemon, so image builds share its BuildKit cache; a commit -# already built on main is rebuilt from cache in seconds. +# Runs on the self-hosted runner in ci/runner (label `linux`), one job at a +# time; building on main too would build every deployed commit twice. Jobs use +# the host's Docker daemon, so image builds share its BuildKit cache. # # Repository settings (Settings → Actions): # secrets.REGISTRY_TOKEN Gitea access token with package write access @@ -63,6 +64,7 @@ jobs: build: needs: test + if: github.ref == 'refs/heads/prod' runs-on: linux steps: - name: Checkout diff --git a/deploy/README.md b/deploy/README.md index 7e26fa4..24aa2f6 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -2,13 +2,15 @@ A `.gitea/workflows/ci.yml` (Gitea Actions) két ágra fut: -- **main**: tesztek, majd image-build. Címkék: a commit hash első 12 karaktere és `main`. -- **prod**: ugyanez, majd telepítés a szerverre. Címkék: hash, `prod` és `latest`. Élesíteni tehát úgy kell, hogy a main-t a prod-ba mergeled (vagy pusholod). +- **main**: csak tesztek. +- **prod**: tesztek, image-build, majd telepítés a szerverre. Címkék: a commit hash első 12 karaktere, `prod` és `latest`. Élesíteni tehát úgy kell, hogy a main-t a prod-ba mergeled (vagy pusholod). + +A runner egyszerre egy feladatot futtat; ha a main is buildelne, minden kitett commit kétszer épülne, és a két futás feladatai egymás közé ékelődnének. A fordítási hibák (például a frontend TypeScript-ellenőrzése) így a prod buildben derülnek ki, ezért kitétel előtt helyben is érdemes buildelni. A lépések: 1. **test**: `cargo test` a backendre, a workerre, a db-re, a horoscope-clientre és a service-kitre, egy Postgres szolgáltatás-konténerrel. -2. **build**: megépíti a négy image-et, és feltölti őket a `registry.sagifer.com/sagifer/sorsfonalak-` címre. A frontend buildje a TypeScript-típusokat is ellenőrzi. Egy main-en már megépült commit a cache-ből pár mp alatt újraépül. +2. **build** (csak prod): megépíti a négy image-et, és feltölti őket a `registry.sagifer.com/sagifer/sorsfonalak-` címre. A frontend buildje a TypeScript-típusokat is ellenőrzi. 3. **deploy** (csak prod): felmásolja a `docker-compose.yml`-t és a `Caddyfile`-t a szerverre, beírja az új `TAG`-et a szerveren lévő `.env`-be, majd `docker compose pull && up -d`. Az adatbázis-migrációk a backend indulásakor futnak le. 4. **release** (csak prod, a deploy után): létrehoz egy `v<év.hónap.nap>-` taget és Gitea-release-t az előző release óta bekerült commitok listájával (repó → Releases).