File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI-CD Deploy to ECS
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+
7+ env :
8+ AWS_REGION : us-east-1
9+ ECR_REPOSITORY : ci-cd-app
10+ ECS_CLUSTER : ci-cd-cluster
11+ ECS_SERVICE : ci-cd-service
12+ ECS_TASK_DEFINITION : ci-cd-task
13+ CONTAINER_NAME : ci-cd-app
14+
15+ jobs :
16+ deploy :
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout repo
21+ uses : actions/checkout@v3
22+
23+ - name : Configure AWS credentials
24+ uses : aws-actions/configure-aws-credentials@v4
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 }}
29+
30+ - name : Login to ECR
31+ uses : aws-actions/amazon-ecr-login@v2
32+
33+ - name : Build Docker image
34+ run : |
35+ docker build -t $ECR_REPOSITORY:latest .
36+
37+ - name : Tag image
38+ run : |
39+ docker tag $ECR_REPOSITORY:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/$ECR_REPOSITORY:latest
40+
41+ - name : Push image
42+ run : |
43+ docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/$ECR_REPOSITORY:latest
44+
45+ - name : Update ECS service (force new deployment)
46+ run : |
47+ aws ecs update-service \
48+ --cluster $ECS_CLUSTER \
49+ --service $ECS_SERVICE \
50+ --force-new-deployment
You can’t perform that action at this time.
0 commit comments