This repository demonstrates a monorepo setup with 5 microservices and GitHub Actions workflows that provide granular, manual control over testing and deployment to multiple environments.
This monorepo contains 5 microservices:
- Service A - User Management (
services/service-a
) - Handles user registration, authentication, and profile management - Service B - Product Catalog (
services/service-b
) - Manages product inventory and catalog - Service C - Order Management (
services/service-c
) - Processes and tracks customer orders - Service D - Payment Service (
services/service-d
) - Handles payment processing and refunds - Service E - Notification Service (
services/service-e
) - Manages email, SMS, and push notifications
- Comprehensive Test Suite: Each service has its own unit tests
- CI/CD Integration: Tests run automatically on push/PR
- Multi-Node Testing: Tests run on Node.js 18.x and 20.x
- Manual Deployment Triggers: Choose exactly which services to deploy
- Multi-Environment Support: Deploy to 5 different environments (dev, staging, test1, test2, prod)
- Selective Service Deployment: Deploy one, some, or all services as needed
- Dry Run Support: Test deployment workflows without actual deployment
- Path-based Filtering: Automatically detect which services have changed
- Optimized Testing: Only run tests for services that have been modified
mono-multi-trigger-russel/
โโโ .github/workflows/ # GitHub Actions workflows
โ โโโ test-all.yml # Automated testing workflow
โ โโโ deploy-manual.yml # Manual deployment workflow
โโโ services/ # Microservices directory
โ โโโ service-a/ # User Management Service
โ โ โโโ src/index.js
โ โ โโโ __tests__/
โ โ โโโ package.json
โ โโโ service-b/ # Product Catalog Service
โ โโโ service-c/ # Order Management Service
โ โโโ service-d/ # Payment Service
โ โโโ service-e/ # Notification Service
โโโ package.json # Root package.json with workspace config
โโโ README.md # This file
- Node.js 18.x or 20.x
- npm
- Clone the repository:
git clone https://github.com/octodemo/mono-multi-trigger-russel.git
cd mono-multi-trigger-russel
- Install dependencies:
npm install
- Run all tests:
npm test
- Run tests for a specific service:
npm run test:service-a # or service-b, service-c, service-d, service-e
- Start a specific service:
npm run start:service-a # Starts on port 3001
npm run start:service-b # Starts on port 3002
npm run start:service-c # Starts on port 3003
npm run start:service-d # Starts on port 3004
npm run start:service-e # Starts on port 3005
Triggers:
- Push to
main
ordevelop
branches - Pull requests to
main
ordevelop
branches
What it does:
- Runs all tests across all services
- Tests on multiple Node.js versions (18.x, 20.x)
- Detects which services have changed using path filters
- Provides detailed test results
Trigger: Manual workflow dispatch from GitHub Actions UI
Inputs:
- Services: Comma-separated list of services to deploy (e.g.,
service-a,service-c
) - Environment: Target environment (
dev
,staging
,test1
,test2
,prod
) - Version: Version/tag to deploy (default:
latest
) - Dry Run: Whether to perform a dry run without actual deployment
What it does:
- Validates input services against available services
- Runs full test suite to ensure code quality
- Deploys selected services to chosen environment in parallel
- Performs health checks and verification
- Provides comprehensive deployment summary
- Go to the Actions tab in GitHub
- Select Manual Deployment workflow
- Click Run workflow
- Configure your deployment:
- Services: Choose which services to deploy (e.g.,
service-a,service-b
) - Environment: Select target environment
- Version: Specify version (optional)
- Dry Run: Check for testing without actual deployment
- Services: Choose which services to deploy (e.g.,
- Click Run workflow
Deploy all services to development:
- Services:
service-a,service-b,service-c,service-d,service-e
- Environment:
dev
Deploy only user and payment services to staging:
- Services:
service-a,service-d
- Environment:
staging
Test deployment workflow (dry run):
- Services:
service-c
- Environment:
test1
- Dry Run: โ (checked)
GET /health
- Health checkGET /users
- List all usersGET /users/:id
- Get specific userPOST /users
- Create new userPUT /users/:id
- Update userDELETE /users/:id
- Delete user
GET /health
- Health checkGET /products
- List products (supports?category=
filter)GET /products/:id
- Get specific productPOST /products
- Create new productPUT /products/:id
- Update productDELETE /products/:id
- Delete product
GET /health
- Health checkGET /orders
- List orders (supports?userId=
and?status=
filters)GET /orders/:id
- Get specific orderPOST /orders
- Create new orderPUT /orders/:id/status
- Update order status
GET /health
- Health checkGET /payments
- List payments (supports?orderId=
and?status=
filters)GET /payments/:id
- Get specific paymentPOST /payments
- Process new paymentPOST /payments/:id/refund
- Process refund
GET /health
- Health checkGET /notifications
- List notifications (supports filters)GET /notifications/:id
- Get specific notificationPOST /notifications
- Create notificationPOST /notifications/:id/send
- Send notificationGET /notifications/stats/summary
- Get notification statistics
Each service includes comprehensive unit tests covering:
- Health endpoints
- CRUD operations
- Error handling
- Input validation
- Business logic
Run tests using:
# All services
npm test
# Individual services
npm run test:service-a
npm run test:service-b
npm run test:service-c
npm run test:service-d
npm run test:service-e
The system supports deployment to 5 different environments:
- dev - Development environment for feature testing
- staging - Pre-production environment for integration testing
- test1 - First test environment for QA
- test2 - Second test environment for performance testing
- prod - Production environment
Each environment can be configured with different:
- Resource limits
- Environment variables
- Database connections
- External service endpoints
Each service can be configured using environment variables:
PORT
- Service port (defaults: 3001-3005)NODE_ENV
- Environment mode (development/production)LOG_LEVEL
- Logging level- Service-specific configuration variables
The project uses npm workspaces for efficient dependency management:
- Shared dependencies in root
package.json
- Service-specific dependencies in individual
package.json
files - Unified scripts for testing and starting services
Each service provides:
- Health check endpoints (
/health
) - Structured logging
- Basic metrics and statistics
- Error tracking and reporting
- Fork the repository
- Create a feature branch
- Make your changes
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Demo Features Demonstrated:
โ
Monorepo with 5 microservices
โ
Unit tests for all services
โ
Automated testing on code changes
โ
Manual deployment control
โ
Granular service selection
โ
Multi-environment support
โ
Parallel deployment capabilities
โ
Dry run functionality
โ
Change detection and path filtering