Finance Manager CI/CD
I developed a comprehensive CI/CD pipeline for my Finance Manager application that automates everything from integration testing to deployment. The pipeline is entirely managed through GitHub Actions and runs automatically on every code change as well as on a nightly schedule (every 12 AM). Here’s how it works: Workflow Overview Code Changes & Nightly Trigger: Every time code is pushed to the GitHub source repository—or on a nightly schedule—a GitHub workflow is triggered. This workflow orchestrates the entire process: performing integration tests, building and pushing Docker images, and deploying the latest version to our QA environment. Integration Testing: The first stage of the workflow is to run an integration test. The workflow: Launches a Temporary EC2 Instance: A temporary EC2 instance is created using a preconfigured AMI that I prepared based on my QA EC2 machine. This AMI includes Docker, Git, and all required tooling. Clones the Source Repository: The temporary instance clones the Finance Manager source repo. Starts Services via Docker Compose: Using docker-compose up, the instance launches the full stack (Next.js frontend, FastAPI backend, and MySQL database). Performs Smoke Tests: The workflow runs basic smoke tests—such as checking that the frontend responds with the expected content and the backend’s health endpoint returns a healthy status. If the tests fail, the process aborts, and cleanup steps are initiated. Build & Push: If the integration tests pass, the workflow moves to building and pushing Docker images: Clones the Source Repository Again: The CI process pulls the latest code from the source repository. Builds Docker Images: The Next.js frontend and FastAPI backend are built using their respective Dockerfiles. Environment variables (like the Clerk keys, backend URL, and database URL) are passed in as build arguments. Pushes Images to AWS ECR: Once built, the images are tagged appropriately and pushed to AWS ECR, ensuring that the latest versions are available for deployment. Deployment: In the final stage, the pipeline deploys the new images to the QA environment: SSH into the QA EC2 Instance: The workflow SSHes into my QA EC2 machine, which already has a clone of the infra repository. Run Update Script: On the QA instance, a deployment script is executed. This script pulls the latest images from ECR, stops and removes the old containers, and starts new containers with the updated images. This ensures that our website is always serving the latest version. Handling Failures: If any part of the smoke test fails, the workflow cleans up by removing the images pushed to ECR, ensuring that no broken version is deployed.



