1- name : CI/CD Pipeline
2- on :
3- push :
4- branches :
5- - main
6- workflow_dispatch :
1+ # name: CI/CD Pipeline
2+ # on:
3+ # push:
4+ # branches:
5+ # - main
6+ # workflow_dispatch:
77
8- env :
9- AWS_REGION : us-east-1
10- ECR_REPOSITORY : sentiment-analysis-api
8+ # env:
9+ # AWS_REGION: us-east-1
10+ # ECR_REPOSITORY: sentiment-analysis-api
1111
12- jobs :
13- build-and-push :
14- name : Build and Push to ECR
15- runs-on : ubuntu-latest
16- outputs :
17- image : ${{ steps.build-image.outputs.image }}
12+ # jobs:
13+ # build-and-push:
14+ # name: Build and Push to ECR
15+ # runs-on: ubuntu-latest
16+ # outputs:
17+ # image: ${{ steps.build-image.outputs.image }}
1818
19- steps :
20- - name : Checkout code
21- uses : actions/checkout@v3
19+ # steps:
20+ # - name: Checkout code
21+ # uses: actions/checkout@v3
2222
23- - name : Configure AWS credentials
24- uses : aws-actions/configure-aws-credentials@v2
25- with :
26- aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
27- aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28- aws-region : ${{ env.AWS_REGION }}
23+ # - name: Configure AWS credentials
24+ # uses: aws-actions/configure-aws-credentials@v2
25+ # with:
26+ # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+ # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+ # aws-region: ${{ env.AWS_REGION }}
2929
30- - name : Login to Amazon ECR
31- id : login-ecr
32- uses : aws-actions/amazon-ecr-login@v1
30+ # - name: Login to Amazon ECR
31+ # id: login-ecr
32+ # uses: aws-actions/amazon-ecr-login@v1
3333
34- - name : Build, tag, and push image to Amazon ECR
35- id : build-image
36- env :
37- ECR_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
38- IMAGE_TAG : ${{ github.sha }}
39- run : |
40- docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
41- docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
42- docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
43- docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
44- echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
34+ # - name: Build, tag, and push image to Amazon ECR
35+ # id: build-image
36+ # env:
37+ # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
38+ # IMAGE_TAG: ${{ github.sha }}
39+ # run: |
40+ # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
41+ # docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
42+ # docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
43+ # docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
44+ # echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
4545
46- # deploy:
47- # name: Deploy to EC2
48- # needs: build-and-push
49- # runs-on: self-hosted
46+ # # deploy:
47+ # # name: Deploy to EC2
48+ # # needs: build-and-push
49+ # # runs-on: self-hosted
5050
51- # steps:
52- # - name: Configure AWS credentials
53- # uses: aws-actions/configure-aws-credentials@v2
54- # with:
55- # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
56- # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
57- # aws-region: ${{ env.AWS_REGION }}
51+ # # steps:
52+ # # - name: Checkout code
53+ # # uses: actions/checkout@v3
5854
59- # - name: Login to Amazon ECR
60- # id: login-ecr
61- # uses: aws-actions/amazon-ecr-login@v1
55+ # # - name: Create .env file
56+ # # run: |
57+ # # echo "BUCKET_NAME=${{ secrets.BUCKET_NAME }}" > .env
58+ # # echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env
59+ # # echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env
60+ # # echo "AWS_DEFAULT_REGION=${{ env.AWS_REGION }}" >> .env
6261
63- # - name: Stop and remove old container
64- # run: |
65- # docker stop sentiment-api || true
66- # docker rm sentiment-api || true
62+ # # - name: Configure AWS credentials
63+ # # uses: aws-actions/configure-aws-credentials@v2
64+ # # with:
65+ # # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
66+ # # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
67+ # # aws-region: ${{ env.AWS_REGION }}
6768
68- # - name: Pull and deploy new container
69- # env:
70- # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
71- # run: |
72- # docker pull $ECR_REGISTRY/$ECR_REPOSITORY:latest
73-
74- # docker run -d \
75- # --name sentiment-api \
76- # --restart unless-stopped \
77- # -p 80:8000 \
78- # -e BUCKET_NAME=${{ secrets.BUCKET_NAME }} \
79- # -e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
80- # -e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
81- # -e AWS_DEFAULT_REGION=${{ env.AWS_REGION }} \
82- # $ECR_REGISTRY/$ECR_REPOSITORY:latest
69+ # # - name: Login to Amazon ECR
70+ # # id: login-ecr
71+ # # uses: aws-actions/amazon-ecr-login@v1
72+
73+ # # - name: Pull latest image from ECR
74+ # # env:
75+ # # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
76+ # # run: |
77+ # # docker pull $ECR_REGISTRY/$ECR_REPOSITORY:latest
78+
79+ # # - name: Stop and remove existing containers
80+ # # run: |
81+ # # docker-compose down || true
82+
83+ # # - name: Deploy with Docker Compose
84+ # # env:
85+ # # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
86+ # # run: |
87+ # # export IMAGE_TAG=$ECR_REGISTRY/$ECR_REPOSITORY:latest
88+ # # docker-compose up -d
8389
84- # - name: Clean up old images
85- # run: docker image prune -af
90+ # # - name: Clean up old images
91+ # # run: docker image prune -af
8692
87- # - name: Verify deployment
88- # run: |
89- # echo "Waiting for application to start..."
90- # sleep 30
93+ # # - name: Verify deployment
94+ # # run: |
95+ # # echo "Waiting for services to start..."
96+ # # sleep 45
9197
92- # echo "Checking container status..."
93- # docker ps | grep sentiment-api
98+ # # echo "Checking container status..."
99+ # # docker-compose ps
94100
95- # echo "Checking application health..."
96- # curl -f http://localhost:80 /health || exit 1
101+ # # echo "Testing application health..."
102+ # # curl -f http://localhost/health || exit 1
97103
98- # echo "✅ Deployment successful!"
104+ # # echo "✅ Deployment successful!"
0 commit comments