Skip to content

How to write CI/CD

Every Patina Network repo runs GitHub Actions along with TypeScript scripts powered by tahminator/pipeline. This page serves to be the baseline every new pipeline should follow.

You can find fully built examples at

and more.

For deeper dives, see:

  • Secrets: how to read a secret in a pipeline
  • Deployments: tagging, CD, and how releases reach the cluster
  • Automation: slash commands, bots, gated auto-merge

Directory layout

.github/
  workflows/                # thin: trigger, permissions, job graph only
  composite/<name>/action.yml   # reusable step groups, `uses: ./.github/composite/<name>`
  scripts/src/<name>/index.ts   # the actual logic, called via `bun run`

Workflows stay declarative. Composite actions are the reusable "verbs". Imperative logic (parsing PRs, hitting the GitHub API, running kustomize, talking to Pulumi) lives in TypeScript under .github/scripts, not inline run: blocks. See .github/scripts/src/ in any of the four repos. This makes the logic unit-testable; run bun run --cwd .github/scripts test as an explicit step early in the job, right after the shared setup action, before anything else in the pipeline executes.

Baseline conventions

Every workflow file should have:

  1. A schema comment for editor validation, as the first line:
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/github-workflow.json

Every workflow in platform-infra and k8s-manifests has this. codebloom/patchats are inconsistent; add it to new files regardless of what the rest of the repo does.

  1. A run-name that includes the actor's name, so the Actions tab is scannable without opening each run:
run-name: Running continuous integration on ${{ github.actor }}'s commits
  1. A concurrency group that matches the semantics of the job:
  2. Racy/cancelable work (CI on a branch, a PR's own checks) -> group: ci-${{ github.ref }}, cancel-in-progress: true. Pushing a new commit cancels the old commit's still-running pipeline instead of letting both finish, since only the latest commit's result matters.
  3. Work that must never interleave (Pulumi apply, a shared staging database) -> a single fixed group name, cancel-in-progress: false, with a comment explaining why. platform-infra's cd.yaml uses group: cd because concurrent pulumi up runs would corrupt state. codebloom's migrate-command.yml uses group: staging-db-migrations because every PR shares the same staging database.
  4. Single-flight environments (patchats deploy-staging / deploy-prod) -> one fixed group per environment so a second deploy can't start mid-flight.

  5. Least-privilege permissions, set at the workflow level and re-declared per job only where a job needs more. platform-infra's ci.yaml sets contents: read at the top and only adds pull-requests: write on the preview job and contents: write on the createTag job. The test job gets nothing beyond the default. Prefer this job-scoped style over granting contents: write, issues: write, pull-requests: write, checks: write for the whole workflow the way codebloom/patchats do.

  6. Call the shared setup action directly, no wrapper. Call tahminator/pipeline/actions/setup straight from the workflow:

- name: Setup
  uses: tahminator/pipeline/actions/setup@4ee08420b0e0e291761d9c7d5e3983f5b3abbd39 # 1.0.88
  with:
    SECRETS: ${{ toJSON(secrets) }}

Tip

It is recommended that you keep all setup logic inside of .github/workflows/*.yaml instead of moving the setup inside of .github/composite/*.yaml.

Leave the composite workflows for wiring together one or multiple scripts.

Warning

It is no longer recommended to wrap @tahminator/pipeline/actions/setup behind a composite like .github/composite/setup-ci. It is too much of a hassle to keep them in sync.

Instead, if it is missing functionality, ask someone on @Patina-Network/infra for help, or fork tahminator/pipeline, add it yourself, and open a PR back.

  1. Explicit needs: gating. Nothing builds or deploys without its test job(s) passing first; every pipeline in all four repos forms a strict dependency tree (test -> preview/createTag; backendPreTest/e2ePreTest -> backendTests/frontendTests -> buildImage -> deploy).

CI shape (pull_request + push)

Standard shape, seen in patchats/.github/workflows/ci.yml:

on:
  push:
    branches:
      - main
  pull_request:

push is scoped to main only: a feature-branch push already triggers the pull_request event, so an unscoped push trigger would run every job twice per commit. Document that scoping decision in a comment the way patchats does; it's not obvious from the YAML alone.

Job graph: *-pretest (fast, typecheck/lint) -> *-test (needs pretest) -> build. Keep pretest fast and cheap so a broken build fails in seconds, not after a multi-minute test suite runs.

Checklist for a new pipeline

  • [ ] $schema comment on line 1
  • [ ] run-name with ${{ github.actor }}
  • [ ] concurrency group whose cancel-in-progress matches the job's actual safety requirements
  • [ ] permissions declared per job, not blanket write at the top
  • [ ] shared setup action pinned to a commit SHA for each job
  • [ ] jobs that rely on other jobs to pass has needs:
  • [ ] logic lives in .github/scripts, not inline run: blocks (exceptions can be made, but not for a majority)

Examples

Repo File Shows
platform-infra ci.yaml $schema comment, job-scoped permissions, tag creation
platform-infra cd.yaml serialized tag-triggered CD, pulumi up
hello-world-grpc-service ci.yaml / cd.yaml minimal tag-triggered CD, image promotion to a tag
k8s-manifests ci.yaml manifest linting pipeline
k8s-manifests merge-command.yml + OWNERS.yaml OWNERS-gated auto-merge
codebloom ci-cd.yml secrets passthrough, pre-deploy DB schema validation gate
codebloom migrate-command.yml slash-command-driven DB migration
patchats deploy-staging.yml pretest -> test -> build -> migrate -> update-tag pipeline
patchats update-tag composite bumping the image tag in k8s-manifests for GitOps