@@ -63,33 +63,42 @@ jobs:
63
63
64
64
- name : Tag Docker Image
65
65
run : |
66
- docker tag text-classification:latest 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
66
+ docker tag text-classification:latest 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3
67
67
68
68
- name : Push Docker Image to AWS ECR
69
69
run : |
70
- docker push 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
70
+ docker push 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3
71
71
72
72
73
- Deploy-to-EC2 :
74
- runs-on : ubuntu-latest
75
- needs : test-and-package
73
+ # Deploy:
74
+ # runs-on: ubuntu-latest
75
+ # needs: test-and-package
76
76
77
- steps :
77
+ # steps:
78
78
79
- - name : Deploy to EC2
80
-
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 configure set default.region eu-north-1
89
-
90
- aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin 843369994444.dkr.ecr.eu-north-1.amazonaws.com
91
-
92
- docker pull 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:latest
93
- docker stop text-classification || true
94
- docker rm text-classification || true
95
- 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:latest
79
+
80
+ # Zip the required files
81
+ - name : Zip files for deployment
82
+ run : |
83
+ zip -r deployment.zip appspec.yml deploy/scripts/install_dependencies.sh deploy/scripts/start_docker.sh
84
+
85
+ # Upload the ZIP file to S3
86
+ - name : Upload ZIP to S3
87
+ if : success()
88
+ run : |
89
+ aws s3 cp deployment.zip s3://text-classification-appspec-bucket/deployment.zip
90
+
91
+ # Deploy to AWS CodeDeploy using the uploaded ZIP file
92
+ - name : Deploy to AWS CodeDeploy
93
+ if : success()
94
+ run : |
95
+ aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
96
+ aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
97
+ aws deploy create-deployment \
98
+ --application-name MyDockerApp \
99
+ --deployment-config-name CodeDeployDefault.OneAtATime \
100
+ --deployment-group-name MyDeploymentGroup \
101
+ --s3-location bucket=text-classification-appspec-bucket,key=deployment.zip,bundleType=zip \
102
+ --file-exists-behavior OVERWRITE \
103
+ --region eu-north-1
104
+
0 commit comments