Welcome to the DevOps guide for the React Starter project. This document is designed to help engineers understand the DevOps practices, tools, and workflows used in this TypeScript monorepo.
DevOps in this project focuses on automation, reliability, and maintainability across a monorepo structure containing multiple workspaces. The main goals are to ensure code quality, automate testing across all packages, validate infrastructure as code, and streamline deployment processes to AWS. All workflows are designed to work seamlessly with the monorepo's workspace architecture.
The project uses a monorepo with the following workspaces:
packages/web- Frontend React application built with Vitepackages/infra- AWS CDK infrastructure as codepackages/shared- Shared utilities, types, and components used across workspaces
- Purpose: Automates CI/CD workflows, including running tests across all workspaces, building the project, validating infrastructure as code, and deploying to AWS.
- Location: All workflow files are stored in the
.github/workflows/directory. - Monorepo Integration: All workflows use workspace-scoped npm commands (with
-wflag) to run tasks in specific packages and maintain workspace isolation. - Key Workflows:
- CI (Continuous Integration): Validates pull requests by linting, formatting, building, and testing all packages (web and infrastructure).
- Code Quality: Performs automated code quality checks, test coverage analysis (per-package), security audits, and dependency analysis on a schedule and on push to main.
- Deploy to DEV: Automatically deploys the application to the development environment on every push to main.
- Deploy to QA: Deploys the application to the QA environment when pushing to release branches.
- Deploy to PROD: Deploys the application to production when publishing GitHub releases.
The project uses GitHub Actions for CI/CD. Below is a detailed description of each workflow:
- Purpose: Validates every pull request to the
mainbranch by linting, formatting, building, and testing all packages (web and infrastructure). - Triggers:
- On pull requests targeting the
mainbranch - Manual: Via GitHub Actions UI (
workflow_dispatch)
- On pull requests targeting the
- Concurrency:
- Ensures only one workflow runs per branch/ref at a time; cancels in-progress runs for the same branch/ref.
- Timeout: 10 minutes
- Prerequisites:
- GitHub Actions variables must be configured:
ENV_CI- Application environment variables for CICDK_ENV_DEV- CDK infrastructure environment configuration for DEVAWS_ROLE_ARN_DEV- AWS IAM Role ARN for development environmentAWS_REGION- AWS region for deployment
- GitHub Actions variables must be configured:
- Main Steps:
- Checkout repository
- Setup Node.js (from
.nvmrc, with npm cache) - Install dependencies (
npm ci- installs for all workspaces) - Create web package
.envfile inpackages/web/from variables (ENV_CI) - Create infra package
.envfile inpackages/infra/from variables (CDK_ENV_DEV) - Lint code across all workspaces (
npm run lint) - Check code formatting (
npm run format:check) - Build application (
npm run build- builds all packages) - Run unit tests with coverage across all packages (
npm run test:coverage) - Build Storybook for web package (
npm run build:storybook -w packages/web) - Configure AWS credentials using OIDC (role:
AWS_ROLE_ARN_DEV) - Synthesize CDK stacks for infra package (
npm run synth -w packages/infra) - Clean up sensitive files (
.envinpackages/web/andpackages/infra/, build artifacts)
- Importance: Ensures that all code merged into
mainpasses linting, formatting, builds successfully, is covered by tests, and that the AWS CDK infrastructure code is valid and synthesizes correctly. This prevents broken or low-quality code from being merged and keeps the main branch stable.
- Purpose: Automates comprehensive code quality checks, test coverage analysis (per-package), security audits, and dependency analysis across all workspaces.
- Triggers:
- Scheduled: Every Sunday at 5 AM UTC
- Manual: Via GitHub Actions UI (
workflow_dispatch) - On push to
mainbranch (if source files, package.json, or workflow files change)
- Timeout: 10 minutes
- Main Steps:
- Checkout repository (with full history for better analysis)
- Setup Node.js (from
.nvmrc, with npm cache) - Install dependencies for all workspaces (
npm ci) - Create web package
.envfile inpackages/web/from variables (ENV_CI) - Create infra package
.envfile inpackages/infra/from variables (CDK_ENV_DEV) - Run ESLint across all workspaces with detailed output summary
- Check code formatting with Prettier
- Build check across all packages
- Security audit (
npm auditfor moderate vulnerabilities) - Package analysis (
npm outdated) - Run web tests with coverage (
npm run test:coverage -w packages/web) - Generate web coverage summary table from
packages/web/coverage/coverage-summary.json - Run infrastructure tests with coverage (
npm run test:coverage -w packages/infra) - Generate infrastructure coverage summary table from
packages/infra/coverage/coverage-summary.json - Archive test results and analysis outputs as artifacts (retention: 7 days)
- Output Format: All results are summarized in the GitHub Actions step summary for easy review in the UI, including per-package coverage tables
- Importance: Maintains code quality, security posture, and up-to-date dependencies across all workspaces. Provides visibility into test coverage and build health for each package. Acts as an early detection system for quality issues, security vulnerabilities, and outdated packages.
- Purpose: Automatically builds and deploys all packages (web and infrastructure) to the development environment on AWS with full infrastructure provisioning.
- Triggers:
- On push to the
mainbranch - On push of the
devtag - Manual: Via GitHub Actions UI (
workflow_dispatch)
- On push to the
- Concurrency:
- Prevents concurrent deployments; ensures orderly deployment
- Prerequisites:
- GitHub Actions variables must be configured:
AWS_ROLE_ARN_DEV- AWS IAM Role ARN for development environmentAWS_REGION- AWS region for deployment (default:us-east-1)ENV_DEV- Application environment variablesCDK_ENV_DEV- CDK infrastructure environment configuration
- GitHub Actions variables must be configured:
- Execution: Calls the reusable
deploy-reusable.ymlworkflow with environment-specific configuration - Importance: Enables rapid deployment of latest changes to development environment for testing and validation. Ensures infrastructure-as-code is always in sync with application deployments.
- Purpose: Deploys all packages (web and infrastructure) to the QA environment on AWS for testing and quality assurance.
- Triggers:
- On push to
release/*branches - On push of the
qatag
- On push to
- Concurrency:
- Prevents concurrent deployments; ensures orderly deployment
- Prerequisites:
- GitHub Actions variables must be configured:
AWS_ROLE_ARN_QA- AWS IAM Role ARN for QA environmentAWS_REGION- AWS region for deploymentENV_QA- Application environment variablesCDK_ENV_QA- CDK infrastructure environment configuration
- GitHub Actions variables must be configured:
- Execution: Calls the reusable
deploy-reusable.ymlworkflow with environment-specific configuration - Importance: Allows testing of release branches in a QA environment before deploying to production.
- Purpose: Deploys all packages (web and infrastructure) to the production environment on AWS when releasing to production.
- Triggers:
- On GitHub release publication
- On push of the
prodtag
- Concurrency:
- Prevents concurrent deployments; ensures orderly deployment
- Prerequisites:
- GitHub Actions variables must be configured:
AWS_ROLE_ARN_PROD- AWS IAM Role ARN for production environmentAWS_REGION- AWS region for deploymentENV_PROD- Application environment variablesCDK_ENV_PROD- CDK infrastructure environment configuration
- GitHub Actions variables must be configured:
- Execution: Calls the reusable
deploy-reusable.ymlworkflow with environment-specific configuration - Importance: Ensures controlled, traceable deployments to production. Using GitHub releases provides a clear release history and version tracking.
- Purpose: Reusable workflow that handles the complete deployment process for any environment. Centralizes deployment logic used by all environment-specific workflows (
deploy-dev.yml,deploy-qa.yml,deploy-prod.yml). - Triggers:
- Called by other workflows via
workflow_call
- Called by other workflows via
- Inputs (from calling workflow):
aws_role_arn- AWS IAM role ARN for the target environment (required)aws_region- AWS region for deployment (default:us-east-1)env- Environment name (dev, qa, prod; default:dev)env_file- Application environment variables (required)cdk_env_file- CDK infrastructure environment configuration (required)
- Timeout: 30 minutes
- Permissions:
id-token: write- For AWS OIDC authenticationcontents: read- For reading repository
- Main Steps:
- Checkout repository
- Setup Node.js (from
.nvmrc, with npm cache) - Install dependencies for all workspaces (
npm ci) - Create web package
.envfile inpackages/web/with:- Environment variables from input
- Build metadata: date (UTC), time (UTC), commit SHA
- Environment code and workflow information
- Create infrastructure
.envfile inpackages/infra/with environment variables - Build all packages (
npm run build) - Build Storybook for web package (
npm run build:storybook -w packages/web) - Configure AWS credentials using OIDC (no long-lived credentials)
- Bootstrap CDK (checks if CDKToolkit stack exists, skips if already bootstrapped):
- Attempts to describe CDKToolkit CloudFormation stack
- Runs
npx cdk bootstraponly if not already bootstrapped
- Synthesize CDK stacks for infra package (
npm run synth -w packages/infra) - Deploy CDK stacks for infra package (
npm run deploy:all -w packages/infrawith auto-approval) - Clean up sensitive files (
.envfiles and build artifacts in all packages)
- Build Metadata: The following environment variables are injected at build time (accessible in the React app as
import.meta.env.*):VITE_BUILD_DATE- Build date (UTC, format: YYYY-MM-DD)VITE_BUILD_TIME- Build time (UTC, format: HH:MM:SS)VITE_BUILD_TS- Full build timestamp (UTC, ISO format)VITE_BUILD_COMMIT_SHA- Git commit SHAVITE_BUILD_ENV_CODE- Environment code (dev/qa/prod)VITE_BUILD_WORKFLOW_NAME- GitHub workflow nameVITE_BUILD_WORKFLOW_RUN_NUMBER- Workflow run numberVITE_BUILD_WORKFLOW_RUN_ATTEMPT- Workflow run attempt (useful for retries)
- Security Features:
- Uses OIDC for AWS authentication (no long-lived credentials stored)
- Automatic cleanup of sensitive files after deployment
- Proper IAM role assumption with session naming
- Bootstrap check prevents unnecessary re-bootstrapping
- Monorepo Integration: All build and deploy commands use workspace-scoped flags (
-w packages/infra,-w packages/web) to target specific packages and maintain workspace isolation. - Importance: Provides a consistent, repeatable deployment process across all environments. Centralizes deployment logic to eliminate duplication between environment-specific workflows. Includes comprehensive build metadata for debugging and version tracking in deployed applications.
GitHub Actions variables should be configured in the repository settings:
AWS_REGION- AWS region for deployments (e.g.,us-east-1)AWS_ROLE_ARN_DEV- AWS IAM role ARN for developmentAWS_ROLE_ARN_QA- AWS IAM role ARN for QAAWS_ROLE_ARN_PROD- AWS IAM role ARN for productionENV_CI- Environment variables for CI workflow (application)ENV_DEV- Environment variables for DEV deployment (application)ENV_QA- Environment variables for QA deployment (application)ENV_PROD- Environment variables for PROD deployment (application)CDK_ENV_DEV- CDK infrastructure environment configuration for DEVCDK_ENV_QA- CDK infrastructure environment configuration for QACDK_ENV_PROD- CDK infrastructure environment configuration for PROD
Each environment variable file should be in the format KEY=VALUE with one entry per line.
Trigger: Push to main branch or push dev tag
Development deployments happen automatically whenever code is merged to the main branch, enabling rapid iteration and continuous deployment of the latest code.
Trigger: Push to release/* branches or push qa tag
QA deployments are triggered when code is pushed to release branches, allowing testing of release candidates in a controlled environment before production deployment.
Trigger: GitHub release published or push prod tag
Production deployments are manually controlled through GitHub releases, providing a clear release history, version tracking, and explicit control over what goes to production.
If you have questions or need help, reach out to your team or check the documentation above.