Files
Vector/.gitea/workflows/ci.yaml
T
josh acf6fc1103
CI / Lint · Typecheck · Test · Build (push) Failing after 43s
CI / Playwright (smoke) (push) Has been skipped
CI / Build & push images (push) Has been skipped
feat(deploy): containerize api + web for single-host docker-compose
- apps/api/Dockerfile: multi-stage build, runs prisma migrate deploy on
  boot. Workspace package.json "main/exports" rewritten to dist so Node
  ESM resolves compiled JS at runtime.
- apps/web/Dockerfile + nginx.conf: static build served by nginx with
  SPA fallback, gzip, cache-bust on hashed assets, and /api reverse
  proxy to the internal api service.
- docker-compose.yml: production-oriented stack — api (SQLite on a
  named volume), web (exposes WEB_PORT), redis (for the upcoming
  worker). Postgres dropped since schema still targets SQLite.
- .dockerignore: keep build context lean.
- ci: add docker job gated on push-to-main that builds and pushes both
  images to ${{ vars.REGISTRY_URL }} using ${{ secrets.REGISTRY_TOKEN }}.
  Tags :latest + :${github.sha}.
2026-04-16 21:10:04 -04:00

132 lines
3.6 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
# Cancel superseded runs on the same branch — saves runner minutes on rapid pushes.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
PNPM_VERSION: 10.33.0
NODE_VERSION: 22
jobs:
check:
name: Lint · Typecheck · Test · Build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Generate Prisma client
run: pnpm -C packages/db exec prisma generate
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Unit tests (with coverage on api)
run: |
pnpm -C packages/shared test
pnpm -C apps/api test:coverage
- name: Build
run: pnpm build
- name: Upload API coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: api-coverage
path: apps/api/coverage
if-no-files-found: ignore
retention-days: 7
e2e:
name: Playwright (smoke)
runs-on: ubuntu-latest
timeout-minutes: 20
# E2E needs a real DB + running stack. Flip this on by setting the `ENABLE_E2E`
# repo variable to `true` in Gitea after the Postgres-in-CI follow-up lands.
if: ${{ vars.ENABLE_E2E == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- run: pnpm install --frozen-lockfile
- run: pnpm -C packages/db exec prisma generate
- run: pnpm -C apps/e2e exec playwright install --with-deps chromium
- run: pnpm -C apps/e2e test
env:
BASE_URL: ${{ secrets.E2E_BASE_URL }}
TEST_USERNAME: ${{ secrets.E2E_USERNAME }}
TEST_PASSWORD: ${{ secrets.E2E_PASSWORD }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: apps/e2e/playwright-report
retention-days: 7
docker:
name: Build & push images
runs-on: ubuntu-latest
needs: check
# Only push from main, and only on direct pushes (not PRs from forks).
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Log in to ${{ vars.REGISTRY_URL }}
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ vars.REGISTRY_URL }}" --username "${{ github.actor }}" --password-stdin
- name: Build & push API image
run: |
IMAGE="${{ vars.REGISTRY_URL }}/vector-api"
docker build \
-f apps/api/Dockerfile \
-t "$IMAGE:${{ github.sha }}" \
-t "$IMAGE:latest" \
.
docker push "$IMAGE:${{ github.sha }}"
docker push "$IMAGE:latest"
- name: Build & push Web image
run: |
IMAGE="${{ vars.REGISTRY_URL }}/vector-web"
docker build \
-f apps/web/Dockerfile \
-t "$IMAGE:${{ github.sha }}" \
-t "$IMAGE:latest" \
.
docker push "$IMAGE:${{ github.sha }}"
docker push "$IMAGE:latest"
- name: Log out
if: always()
run: docker logout "${{ vars.REGISTRY_URL }}"