← Back to index

Monorepo Template

Multi-app monorepo with per-app child pipelines. Supports React web apps and serverless Next.js apps in the same repo.

Setup

Recommended: External CI/CD Configuration

Go to Settings > CI/CD > General pipelines and set CI/CD configuration file to:

https://gitlab-ci-yaml-template.enouvo.com/monorepo/.gitlab-ci.yml

Alternative: Include in .gitlab-ci.yml

include:
  - 'https://gitlab-ci-yaml-template.enouvo.com/monorepo/.gitlab-ci.yml'

Required Variables

GITLAB_CI_ACCESS_TOKENToken to download ci-scripts (set by admin at group level)
GITLAB_CI_MONOREPO_WEB_REACT_APPSComma-separated React app names (e.g. web-admin,web-app)
GITLAB_CI_MONOREPO_WEB_NETXTJS_APPSComma-separated Next.js app names

Per-App Variables

For each app (e.g. web-admin → variable suffix WEB_ADMIN):

VariableDescription
DOTENV_FILE_WEB_ADMINEnvironment file content for the app
REACT_WEB_TEST_CMD_WEB_ADMINTest command (default: test:web-admin)
SONAR_PROJECT_KEY_WEB_ADMINSonarQube project key (falls back to SONAR_PROJECT_KEY)
SONAR_TOKEN_WEB_ADMINSonarQube token (falls back to SONAR_TOKEN)
AZURE_STATIC_WEB_APPS_DEPLOYMENT_TOKEN_WEB_ADMINAzure SWA deploy token

How It Works

  1. setup_pipelines job generates per-app child pipeline YAML
  2. Each app gets its own child pipeline with lint, test, build, deploy
  3. On merge requests: only lint/test run (build/deploy skipped)
  4. On branch push: full pipeline (lint, test, build, deploy)

Project Structure

monorepo/
├── apps/
│   ├── web-admin/
│   │   ├── package.json
│   │   └── src/
│   └── web-app/
│       ├── package.json
│       └── src/
├── package.json
├── pnpm-workspace.yaml
└── .gitlab-ci.yml