Skip to content
← Engineering handbook

Cloud & DevOps · Backend· 7 min read

Production cloud deployments: automated GitHub Actions CI/CD on AWS EC2 & Azure

Deploying high-availability Node.js and NestJS microservices onto AWS EC2 and Azure VMs. Setting up automated GitHub Actions pipelines, Nginx reverse proxies, PM2 clustering, and SSL rotation.

CI/CDGitHub ActionsAWS EC2Azure CloudDockerDevOps

On this page

Manual SSH deployments are an anti-pattern. If deploying to production requires an engineer to run `git pull` on a server terminal, mistakes are inevitable. Across our deployments at Tedekstra, production backend and frontend services are deployed continuously using automated GitHub Actions CI/CD pipelines targeting AWS EC2 instances and Azure Cloud VMs.

The multi-stage deployment pipeline

StageActions ExecutedFail Fast Gate
1. Lint & AuditESLint, TypeScript compiler check, npm auditFails if type errors or critical vulnerabilities exist
2. Test SuiteUnit tests (Jest), integration tests with test containersFails if code coverage drops below threshold
3. Build & PackageTurbopack build, bundle optimization, Docker image buildFails on compilation warnings treated as errors
4. Cloud DeployAutomated SSH deployment, zero-downtime PM2 reload, health check verifyRolls back to previous release tag if health endpoint fails
yaml
name: Production Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'npm'

      - run: npm ci
      - run: npm run test
      - run: npm run build

      - name: Deploy to Cloud VM
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.HOST_IP }}
          username: ${{ secrets.DEPLOY_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script: |
            cd /var/www/app
            git pull origin main
            npm ci --production
            npm run build
            pm2 reload ecosystem.config.js --update-env
            curl --fail http://localhost:4000/health || exit 1
GitHub Actions workflow deploying to cloud VM with zero downtime.