Skip to content

찜 리팩토링

찜 리팩토링 #108

Workflow file for this run

name: Build, Push to ECR, and Deploy to ECS
on:
push:
branches:
- main # 원하는 브랜치로 변경
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Set up Amazon ECR CLI
id: ecr
run: aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
- name: Build Docker Image
run: docker build -t seungjun23/dockerfile:0.1 .
- name: Push Docker Image to ECR
run: |
docker tag seungjun23/dockerfile:0.1 ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/trendy-backend:latest
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/trendy-backend:latest
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json # 여기서 필요에 따라 파일명 변경
container-name: trendy
image: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/trendy-backend:latest
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
service: ecs-service # ECS 서비스 이름으로 변경
cluster: trendy-healthy-cluster # ECS 클러스터 이름으로 변경
task-definition: ${{ steps.task-def.outputs.task-definition }}
- name: Cleanup
run: docker logout ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com