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
| Stage | Actions Executed | Fail Fast Gate |
|---|---|---|
| 1. Lint & Audit | ESLint, TypeScript compiler check, npm audit | Fails if type errors or critical vulnerabilities exist |
| 2. Test Suite | Unit tests (Jest), integration tests with test containers | Fails if code coverage drops below threshold |
| 3. Build & Package | Turbopack build, bundle optimization, Docker image build | Fails on compilation warnings treated as errors |
| 4. Cloud Deploy | Automated SSH deployment, zero-downtime PM2 reload, health check verify | Rolls 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