Skip to main content

CI/CD Pipeline

Related docs: DEPLOYMENT · Hosting Infrastructure


1. Branching Strategy

The repository follows a simplified two-tier deployment model:

  • main: The integration branch. Corresponds to the Staging environment.
  • production: The release branch. Corresponds to the Live environment.
  • feature/*: Individual feature development.

2. CI Pipeline (GitHub Actions)

Triggered on every Pull Request to main or production:

  • Linting: Ensures code style consistency.
  • Backend Tests: Executes unit and integration tests.
  • Frontend Build: Validates Next.js build integrity.

3. CD Pipeline — Frontend (Vercel)

Vercel is configured with two primary environments:

EnvironmentTracking BranchDomain
Productionproductionpakashop.store
Stagingmainstaging.pakashop.store
Previewfeature/*<branch>.pakashop-pr.vercel.app

4. CD Pipeline — Backend (EC2 via GitHub Actions SSH)

The .github/workflows/deploy.yml workflow manages multi-environment deployments.

4.1 Deployment Workflow Logic

The deployment workflow dynamically targets either the production or staging EC2 instances based on the triggering branch (production or main), ensuring that only validated code reaches the live environment.

4.2 Orchestration (deploy.sh)

The deploy.sh script on the target host handles:

  1. Fetching the latest code from the repository.
  2. Installing necessary dependencies.
  3. Executing database migrations.
  4. Restarting the platform services via systemd.