-
Notifications
You must be signed in to change notification settings - Fork 0
deployment
Kognitika uses three GitHub Actions workflows for continuous integration, production deployment, and Android builds. Direct edits to production server files are forbidden outside documented emergency hotfixes.
File: .github/workflows/ci.yml
Runs on every push to main, master, or codex/** branches, and on every pull request.
Steps:
- Checkout the repository.
- Set up pnpm 10.22.0 and Node.js 22.
- Start a PostgreSQL 15 service container.
- Install dependencies with
pnpm install --frozen-lockfile. - Run
cargo testfor the Rust WASM core atcrates/kognitika-core/. - Run TypeScript lint with
pnpm lint. - Run Vitest unit tests with
pnpm test. - Run
pnpm validate(same as test). - Build the frontend with
pnpm build. - Check bundle size with
pnpm check:bundle. - Install Playwright browsers and run E2E tests with
pnpm test:e2e.
File: .github/workflows/deploy.yml
Runs on every push to main (or manually via workflow_dispatch).
The workflow has two jobs:
Verify -- runs the same checks as the CI workflow (lint, test, build, Rust tests).
Deploy -- runs after verify passes, in the production environment:
- Prepares an SSH connection to the deploy host using secrets (
KOGNITIKA_DEPLOY_HOST,KOGNITIKA_DEPLOY_PORT,KOGNITIKA_DEPLOY_SSH_KEY). - On the server, the deploy script:
- Creates a timestamped backup of the current
dist/directory. - Pulls the latest
mainbranch withgit pull --ff-only. - Verifies the checked-out commit matches the expected SHA.
- Restores cached
dist/assetsto preserve immutable asset URLs. - Runs
pnpm install --frozen-lockfile. - Configures nginx for
kognitika.ruwith TLS via certbot. - Inserts or updates the production
.envfile with the correctAPP_URL,FRONTEND_URL, andCORS_ORIGINvalues. - Runs Prisma migrations with
pnpm exec prisma migrate deploy. - Builds the frontend with
BUILD_HASH=<sha> pnpm build. - Exports and deploys the mobile web version.
- Restarts the
kognitikasystemd service. - Polls
/api/healthup to 30 times (2-second intervals) until the new build responds. - Verifies the health check response contains the expected
buildId.
- Creates a timestamped backup of the current
File: .github/workflows/android.yml
Runs on pushes to main affecting Capacitor-related paths, on pull requests, and manually with optional release flag.
Jobs:
Debug -- builds an unsigned debug APK:
- Checks out the repository.
- Sets up pnpm, Node.js 22, and Java 21 (Temurin).
- Installs dependencies, builds the frontend, synchronizes Capacitor.
- Runs Android unit tests.
- Assembles the debug APK.
- Uploads the APK as a build artifact (retained for 14 days).
GitHub Release -- runs after debug on push to main:
- Downloads the debug APK artifact.
- Deletes the existing
android-latestrelease and tag. - Creates a new
android-latestrelease with the APK attached.
Release -- runs only when workflow_dispatch is triggered with release=true:
- Decodes the Android keystore from a base64 secret.
- Signs and assembles a release App Bundle (AAB).
- Uploads the AAB as a build artifact (retained for 30 days) for Play Console upload.
Normal production changes follow this sequence:
local changes -> git commit -> git push -> GitHub PR -> merge to main -> GitHub Actions deploy
The server updates itself through the repository-first flow. Do not edit files under /opt/kognitika/ or /opt/kognitika/dist/ directly during normal work.
curl https://kognitika.ru/api/healthReturns:
{
"status": "ok",
"timestamp": "2026-07-29T12:00:00.000Z",
"buildId": "abc1234"
}The buildId should match the short commit hash of the deployed version.
For local full-stack deployment:
docker compose up --build- App container: port 3006
- PostgreSQL container: port 5432 (user:
admin, password:adminpassword, database:cognitika)
The Dockerfile is at the project root and uses tsx to run the Express server. The docker-compose.yml defines both services and a health check for the database.