Skip to content

Commit 6cc0331

Browse files
committed
Added ECR EC2 Deployment
1 parent 4da9ae1 commit 6cc0331

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

.github/workflows/cicd.yaml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,24 @@ jobs:
7070
docker push 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
7171
7272
73-
# Deploy-to-EC2:
74-
# runs-on: ubuntu-latest
75-
# needs: test-and-package
73+
Deploy-to-EC2:
74+
runs-on: ubuntu-latest
75+
needs: test-and-package
7676

77-
# steps:
77+
steps:
7878

79-
# - name: Deploy to EC2
80-
# uses: appleboy/ssh-action@v0.1.5
81-
# with:
82-
# host: ${{ secrets.EC2_HOST }}
83-
# username: ${{ secrets.EC2_USER }}
84-
# key: ${{ secrets.EC2_SSH_KEY }}
85-
# script: |
86-
# docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/text-classification-using-mlops:latest
87-
# docker stop my-app || true
88-
# docker rm my-app || true
89-
# docker run -d -p 80:5000 --name my-app -e DAGSHUB_PAT=${{ secrets.DAGSHUB_PAT }} ${{ secrets.DOCKER_HUB_USERNAME }}/text-classification-using-mlops:latest
79+
- name: Deploy to EC2
80+
uses: appleboy/ssh-action@v0.1.5
81+
with:
82+
host: ${{ secrets.EC2_HOST }}
83+
username: ${{ secrets.EC2_USER }}
84+
key: ${{ secrets.EC2_SSH_KEY }}
85+
script: |
86+
aws configure set aws_access_key_id ${{secrets.AWS_ACCESS_KEY_ID }}
87+
aws configure set aws_secret_access_key ${{secrets.AWS_SECRET_ACCESS_KEY }}
88+
aws set default.region eu-north-1
89+
aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin 843369994444.dkr.ecr.eu-north-1.amazonaws.com
90+
docker pull 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
91+
docker stop text-classification || true
92+
docker rm text-classification || true
93+
docker run -d -p 80:5000 -e DAGSHUB_PAT= ${{ secrets.DAGSHUB_PAT }} --name text-classification 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v1

0 commit comments

Comments
 (0)