CI/CD Pipeline Documentation
This documentation provides an overview of the CI/CD pipeline setup for a monorepo that contains a frontend React application and a backend application. The pipeline is designed to handle testing, building, and deploying applications with specific workflows for pull requests and main branch updates.
Workflows
- Test on Pull Request
- CI/CD Pipeline
Workflow 1: Test on Pull Request
This workflow is triggered by pull request events. It runs tests separately for the frontend and backend whenever a pull request is opened, synchronized (updated), or reopened. This ensures that code changes are tested before they are merged into the main branch.
Key Steps:
- Checkout Repository: The workflow checks out the code from the repository.
- Set Up Node.js: It sets up the Node.js environment.
- Install Dependencies: Installs the necessary dependencies for both the React frontend and the backend.
- Run Tests: Executes the test suites for both the frontend and backend to verify that the code changes do not introduce any issues.
Workflow 2: CI/CD Pipeline
This workflow is triggered by push events to the main branch, specifically after a pull request has been merged. It handles the building and deployment of the application.
Key Steps:
- Checkout Repository: The workflow checks out the latest code from the main branch.
- Set Up Docker Buildx: Prepares the environment for Docker multi-platform builds.
- Configure AWS Credentials: Sets up AWS credentials to interact with AWS services like ECR (Elastic Container Registry).
- Log In to Amazon ECR: Authenticates Docker with AWS ECR to enable image pushing.
- Extract Commit SHA: Retrieves the short SHA hash of the latest commit to tag Docker images uniquely.
- Install Pulumi CLI: Sets up Pulumi, a tool for infrastructure as code, to manage cloud resources.
- Install Pulumi Dependencies: Installs the necessary Pulumi dependencies for infrastructure provisioning.
Conditional Deployment
The build job is conditional and runs only if the pull request has been successfully merged. This ensures that deployments are performed only on code that has passed review and testing.