Files
vigilcare-clinical/docs/CICD/onboarding-a-project.md
T
Trent 1c1065938f
CI / changes (push) Successful in 47s
CI / frontend (push) Skipped
CI / backend (push) Successful in 43m10s
Pull MinIO from the Gitea-mirrored pgsty image after upstream Hub/Quay removal.
2026-09-30 23:09:01 +08:00

8.9 KiB

Putting a project on this CI/CD

How to give another repository CI and CD on git.vectur45.com. Assumes the platform is already set up — you are adding a project, not a runner.

Read platform/observed-state.md if anything here surprises you; it is the source of truth and this document is downstream of it.


0. Before you start

You need Where
A repo on git.vectur45.com
Read access to infra/ci-workflows its Settings → Actions → General → collaborative owners must list your repo's owner
A deploy host with Docker + Compose for CD only
A PAT with write:package for CD only — GITEA_TOKEN cannot push to the container registry

There is one runner (gcp-runner-01, label ubuntu-latest) on a 2 vCPU / 8 GB box shared with Gitea and the demo stacks. Jobs run one at a time. Budget wall clock accordingly: an extra job is queued, not parallel.


1. Does your project fit the shared pipelines?

Stack Reusable workflow Status
.NET 8 service with Postgres/Redis dotnet8-ci.yml ✅ in use
Vue 3 / React / Nuxt front end node-ci.yml ✅ in use
Node service with Postgres/RabbitMQ/Redis node-service-ci.yml ✅ sidecars, not services:
Python, React Native, something else — not written yet; see §6

If it fits, you write a caller: a ci.yml that declares uses: and passes inputs. You do not copy pipeline steps. If you find yourself copying steps, that is a signal the workflow needs an input, not that you need a fork.


2. CI — write the caller

.gitea/workflows/ci.yml in your repo:

name: CI

on:
  push:
    branches: [main, master]
    paths: ["src/**", ".gitea/workflows/**"]
  pull_request:
    branches: [main, master]
    paths: ["src/**", ".gitea/workflows/**"]

jobs:
  backend:
    uses: infra/ci-workflows/.gitea/workflows/dotnet8-ci.yml@v1
    with:
      working_directory: .              # dir holding the .sln
      solution: MyApp.sln
      postgres_db: myapp_test
      # Tests that must NOT see the service database — in-memory unit tests.
      # Leaving the connection strings set lets a context factory reach the live
      # Postgres and retry until it thrashes the runner.
      isolated_test_projects: |
        tests/MyApp.UnitTests/MyApp.UnitTests.csproj
      test_projects: |
        tests/MyApp.IntegrationTests/MyApp.IntegrationTests.csproj
      test_env: |
        Jwt__SigningKey=ci-test-jwt-secret-at-least-32-bytes-long!!

Front end, in the same file or its own job:

  frontend:
    uses: infra/ci-workflows/.gitea/workflows/node-ci.yml@v1
    with:
      working_directory: web
      node_version: "22"
      lint_command: npm run lint        # typecheck belongs HERE, once
      build_command: npx vite build     # the build must not re-run vue-tsc/tsc

Pin @v1. Never a branch — otherwise every project's CI changes the moment someone edits the shared repo.

Monorepo? Add a changes job that sets outputs from a path diff and gate the callers on it (if: needs.changes.outputs.backend == 'true'). That job stays in your repo: the path map is repo-specific and it needs fetch-depth: 0. See ../.gitea/workflows/ci.yml.


3. CD

CD is not extracted into a reusable workflow yet, because deployment shape varies more than CI. Copy templates/workflows/cd.yml and templates/docker-bake.hcl, then fill the placeholders (<owner>, <repo-slug>) — the templates carry no product names, so nothing has to be grepped out afterwards. See templates/README.md for the copy-to table.

Four things it must keep, all learned the hard way — each links to the reason:

Keep Why
cap-buildx-builder.sh before the bake, and one bake target at a time A default parallel bake takes both cores and returns Gitea 504. BUILDKIT_STEP_MAX_PARALLELISM=1 alone is not enough.
Migrate as its own job, downloading an artifact — never a second docker build Bind mounts resolve on the Docker host, not the job workspace
Scratch migrate-bundle with CMD and docker create IMAGE /out/migrate-api FROM scratch has no default command; bare docker create fails with no command specified
Expand-then-contract migrations Migrate runs while the previous release still serves traffic. Rollback restores the image tag, not the schema.

Secrets (repo → Settings → Actions → Secrets): REGISTRY_USERNAME, REGISTRY_TOKEN (the PAT), DEPLOY_HOST, DEPLOY_USER, DEPLOY_SSH_KEY, plus a migration connection string if you migrate. Variables: REGISTRY, and any public origin baked into a UI image at build time.

Connection strings must be Npgsql key=value form (Host=…;Port=…;Username=…;Password=…), never URI form, with no wrapping quotes — see hybrid-gcp-tailscale-cicd.md.


4. Deploy host

Covered in hybrid-gcp-tailscale-cicd.md. In short: /opt/<app>/ with a docker-compose.prod.yml and a host-owned .env (chmod 600) that CD patches only for the image tag. Same-host dependencies join the external shared-services network and are reached by Docker DNS; remote ones over Tailscale by 100.x address, never MagicDNS.

Copy templates/docker-compose.prod.yml and templates/.env.example.


5. Verify before you call it done

  • CI is green, and the run shows uses: resolving — not a copied pipeline
  • For .NET: the isolated test step ran before the service-backed one
  • A change touching only the front end does not start Postgres
  • Second CI run on an unchanged lockfile shows a cache hit in restore/install
  • CD on a tag: bake → migrate → deploy → smoke, and Gitea stayed up during the bake
  • Rollback path tested once, deliberately
  • No published database ports anywhere in CI
  • upload-artifact / download-artifact both @v4 — they do not interoperate with v3

6. When the shared workflow does not fit

In order of preference:

  1. Add an input to the shared workflow, tag v1.x, update your caller. Callers on @v1 are unaffected until they move.
  2. Use the escape hatches already there — pre_build_command, test_env, extra_check_command — for genuinely repo-specific steps. A reusable workflow cannot accept injected steps, which is why these exist.
  3. Write a new pipeline in infra/ci-workflows for a genuinely different stack (Python, React Native). Model it on dotnet8-ci.yml: same job names, same artifact names, same host-budget caps.
  4. Fork the steps into your repo — last resort, and record why in the repo's README, because it will not receive fixes made to the shared one.

Breaking changes get a new major tag (v2). Projects migrate when they choose. Additive changes get a minor (v1.1) and existing @v1 callers keep working.

Do not fork this directory. Three project kits were created as copies of CICD/ in 2026-09-30 and had diverged within days — one of them made a script strictly worse by replacing an enumerated builder cleanup with a hardcoded name. A project keeps its caller, its cd.yml, its compose/env files, and a link back here. The pipelines live in infra/ci-workflows and the platform facts live in platform/observed-state.md, which describes one runner on one VM — copies of it will disagree, and its whole value is being the one file you can trust.


7. Gitea-specific things that will surprise you

Expectation Reality here
jobs.<id>.environment gates a deploy Ignored. No approval gates — use tag patterns.
runs-on: [label-a, label-b] Documented incomplete. One label.
gitea.event.inputs reaches a reusable workflow It does not (1.27.x). Pass explicit inputs:.
GITEA_TOKEN can push a package It cannot. PAT required.
Tests cannot reach Gitea They can. GITEA_TOKEN is injected into every job — blank it if product code would make live API calls.
A broker works as a services: entry like Postgres does RabbitMQ does not. It fails health before any step runs and no step-level fix is reachable. Use scripts/start-job-sidecars.sh, or node-service-ci.yml which wraps it.
actions/* comes from your instance It comes from github.com by default. builtin:checkout avoids that entirely.
A second CI job runs in parallel It queues. capacity: 1.

Source of truth: platform/observed-state.md · How it got this way: platform/change-log.md · Build speed: ci-cd-build-cache.md