Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/cd-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy AI Platform to ECS

on:
push:
tags:
- 'v*' # Deploy only when tags like v1.0.0, v2.1.0, etc., are created

jobs:
build:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read
attestations: write
id-token: write

steps:
- name: Checkout the repo
uses: actions/checkout@v4

- name: Check if tag is from main branch
id: check-branch
run: |
if [ "$(git branch -r --contains ${{ github.ref }})" == "origin/main" ]; then
echo "IS_MAIN=true" >> $GITHUB_ENV
else
echo "IS_MAIN=false" >> $GITHUB_ENV
fi

- name: Configure AWS credentials
if: env.IS_MAIN == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::024209611402:role/github-action-role
aws-region: ap-south-1

- name: Login to Amazon ECR
if: env.IS_MAIN == 'true'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and Push Docker Image
if: env.IS_MAIN == 'true'
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ github.event.repository.name }}-repo
TAG: ${{ github.ref_name }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$TAG ./backend
docker push $REGISTRY/$REPOSITORY:$TAG

- name: Deploy to ECS
if: env.IS_MAIN == 'true'
run: |
aws ecs update-service \
--cluster ${{ github.event.repository.name }}-cluster \
--service ${{ github.event.repository.name }}-service \
--force-new-deployment