← Back to Frontend System Design Blogs

Deployment, CI/CD, and Environment Management for Angular Ecommerce App

2025-07-02📖 2 min read

Share:

🚀 Introduction

Deploying and maintaining a production-ready ecommerce app requires automation, robust environment handling, and version control. This blog covers best practices for CI/CD, environment management, versioning, and release strategies.


1. Environment Handling

  • Use Angular’s built-in environment files (environment.ts, environment.prod.ts) for config
  • Maintain separate environments for:
    • Development (dev)
    • Staging (stg)
    • Production (prod)
  • Environment variables: API URLs, feature flags, analytics keys
  • Example: Switching API endpoints based on environment

2. Continuous Integration / Continuous Deployment (CI/CD)

  • Automate build, test, and deployment with tools like GitHub Actions, Jenkins, GitLab CI, or CircleCI
  • Workflow:
    1. Code push triggers linting and unit tests
    2. Run E2E tests (Cypress) in a test environment
    3. On success, deploy to staging for QA
    4. Manual approval or automated promotion to production

Sample GitHub Actions Workflow

name: CI/CD Pipeline

on:
  push:
    branches:
      - main
      - develop

jobs:
  build-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: "18"
      - name: Install dependencies
        run: npm ci
      - name: Run unit tests
        run: npm run test -- --watch=false --browsers=ChromeHeadless
      - name: Run Cypress E2E tests
        run: npm run e2e
      - name: Build production app
        run: npm run build -- --prod

  deploy:
    needs: build-test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - name: Deploy to Production Server
        run: ./deploy.sh

3. Versioning and Releases

Use semantic versioning (SemVer): MAJOR.MINOR.PATCH Create Git tags for releases Maintain changelog for transparency Code reviews and pull requests mandatory before merging to main branch


4. Rollback and Monitoring

Keep backups and old builds for quick rollback Use monitoring tools (Sentry, New Relic) for error tracking Set up alerts for downtime or performance degradation


5. Security Considerations

Store secrets securely (GitHub Secrets, Vault) Use HTTPS and secure headers Regular dependency audits and updates


📌 Summary

A robust deployment pipeline, solid environment management, and version control strategy are keys to smooth and reliable production releases.