https://github.com/octodemo/mono-multi-trigger-russel
https://github.com/octodemo/mono-multi-trigger-russel
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/octodemo/mono-multi-trigger-russel
- Owner: octodemo
- Created: 2025-08-20T14:30:42.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-20T17:49:34.000Z (10 months ago)
- Last Synced: 2025-08-20T18:32:25.659Z (10 months ago)
- Language: JavaScript
- Size: 6.36 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Monorepo Multi-Service Deployment Demo
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.
## ๐๏ธ Architecture Overview
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
## ๐ Features
### โ
Automated Testing
- **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
### ๐ฏ Granular Deployment Control
- **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
### ๐ Change Detection
- **Path-based Filtering**: Automatically detect which services have changed
- **Optimized Testing**: Only run tests for services that have been modified
## ๐ Project Structure
```
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
```
## ๐ ๏ธ Getting Started
### Prerequisites
- Node.js 18.x or 20.x
- npm
### Installation
1. Clone the repository:
```bash
git clone https://github.com/octodemo/mono-multi-trigger-russel.git
cd mono-multi-trigger-russel
```
2. Install dependencies:
```bash
npm install
```
3. Run all tests:
```bash
npm test
```
4. Run tests for a specific service:
```bash
npm run test:service-a # or service-b, service-c, service-d, service-e
```
5. Start a specific service:
```bash
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
```
## ๐ Workflows
### 1. Automated Testing (`test-all.yml`)
**Triggers:**
- Push to `main` or `develop` branches
- Pull requests to `main` or `develop` 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
### 2. Manual Deployment (`deploy-manual.yml`)
**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:**
1. Validates input services against available services
2. Runs full test suite to ensure code quality
3. Deploys selected services to chosen environment in parallel
4. Performs health checks and verification
5. Provides comprehensive deployment summary
## ๐ฎ How to Use Manual Deployment
1. Go to the **Actions** tab in GitHub
2. Select **Manual Deployment** workflow
3. Click **Run workflow**
4. 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
5. Click **Run workflow**
### Example Deployment Scenarios
**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)
## ๐ Service APIs
### Service A - User Management (Port 3001)
- `GET /health` - Health check
- `GET /users` - List all users
- `GET /users/:id` - Get specific user
- `POST /users` - Create new user
- `PUT /users/:id` - Update user
- `DELETE /users/:id` - Delete user
### Service B - Product Catalog (Port 3002)
- `GET /health` - Health check
- `GET /products` - List products (supports `?category=` filter)
- `GET /products/:id` - Get specific product
- `POST /products` - Create new product
- `PUT /products/:id` - Update product
- `DELETE /products/:id` - Delete product
### Service C - Order Management (Port 3003)
- `GET /health` - Health check
- `GET /orders` - List orders (supports `?userId=` and `?status=` filters)
- `GET /orders/:id` - Get specific order
- `POST /orders` - Create new order
- `PUT /orders/:id/status` - Update order status
### Service D - Payment Service (Port 3004)
- `GET /health` - Health check
- `GET /payments` - List payments (supports `?orderId=` and `?status=` filters)
- `GET /payments/:id` - Get specific payment
- `POST /payments` - Process new payment
- `POST /payments/:id/refund` - Process refund
### Service E - Notification Service (Port 3005)
- `GET /health` - Health check
- `GET /notifications` - List notifications (supports filters)
- `GET /notifications/:id` - Get specific notification
- `POST /notifications` - Create notification
- `POST /notifications/:id/send` - Send notification
- `GET /notifications/stats/summary` - Get notification statistics
## ๐งช Testing
Each service includes comprehensive unit tests covering:
- Health endpoints
- CRUD operations
- Error handling
- Input validation
- Business logic
Run tests using:
```bash
# 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
```
## ๐ Deployment Environments
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
## ๐ง Configuration
### Environment Variables
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
### Workspace Configuration
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
## ๐ Monitoring & Observability
Each service provides:
- Health check endpoints (`/health`)
- Structured logging
- Basic metrics and statistics
- Error tracking and reporting
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Ensure all tests pass
5. Submit a pull request
## ๐ License
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