CI/CD pipeline using GitHub Actions, Docker, ECR, ECS Fargate & Load Balancer
This project uses a fully automated CI/CD deployment pipeline. Every push to main builds a Docker image, pushes it to ECR, updates ECS task definitions, and redeploys the service behind an Application Load Balancer.
Push triggers workflow → builds Docker image → deploys to AWS.
GitHub builds the Docker image using your Dockerfile.
The Docker image is pushed to Amazon Elastic Container Registry.
Task definition updates automatically with the new image.
Fargate deploys the updated container serverlessly.
ALB routes traffic and keeps the app always available.
name: Deploy to Amazon ECS
on:
push:
branches: [ "main" ]
env:
AWS_REGION: ap-south-1
ECR_REPOSITORY: node/mk-pipeline
ECS_SERVICE: mk-task-definition-service-8pqtz7f5
ECS_CLUSTER: mk-cluster
ECS_TASK_DEFINITION: .aws/task-definition.json
CONTAINER_NAME: mk-container
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- uses: aws-actions/amazon-ecr-login@v1
- name: Build Docker Image
run: |
docker build -t ... (trimmed)