Update README.md #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Amazon ECR | |
| on: | |
| push: | |
| branches: [ "develop" ] # develop 브랜치에 push될 때 실행 | |
| env: | |
| AWS_REGION: us-east-1 | |
| jobs: | |
| deploy: | |
| name: Build and Push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # 1. AWS 인증 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| # 2. ECR 로그인 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Debug AWS Region | |
| run: | | |
| echo "AWS_REGION=$AWS_REGION" | |
| echo "AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION" | |
| - name: Debug ECR Registry | |
| run: echo "${{ steps.login-ecr.outputs.registry }}" | |
| # 3. API 서버 빌드 및 푸시 | |
| - name: Build and Push API Image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: mopl-api # 아까 만든 ECR 이름 | |
| IMAGE_TAG: latest | |
| run: | | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./services/api | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| # 4. Batch 서버 빌드 및 푸시 | |
| - name: Build and Push Batch Image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: mopl-batch | |
| IMAGE_TAG: latest | |
| run: | | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./services/batch | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| # 5. Gateway(Nginx) 빌드 및 푸시 | |
| - name: Build and Push Gateway Image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: mopl-gateway | |
| IMAGE_TAG: latest | |
| run: | | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./services/gateway | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |