Merge pull request #104 from hyoni-ch/docu/#94 #53
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 Next.js to EC2 with CodeDeploy | |
| on: | |
| push: | |
| branches: [main] # 배포 브랜치! | |
| jobs: | |
| deploy: | |
| name: Build & Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '22' | |
| - name: Install dependencies & build | |
| run: | | |
| npm ci | |
| npm install | |
| - name: Prepare deploy artifact | |
| run: | | |
| zip -r joyuri.zip . -x ".next/*" "node_modules/*" ".github/*" "*.DS_Store" | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| # - name: Upload to S3 | |
| # run: | | |
| # aws s3 cp joyuri.zip s3://mybucket-ces-joyuri/front/joyuri.zip | |
| # - name: Trigger CodeDeploy deployment | |
| # run: | | |
| # aws deploy create-deployment \ | |
| # --application-name next-js-app \ | |
| # --deployment-group-name next-js-dg \ | |
| # --s3-location bucket=mybucket-ces-joyuri,bundleType=zip,key=front/joyuri.zip \ | |
| # --deployment-config-name CodeDeployDefault.AllAtOnce \ | |
| # --file-exists-behavior OVERWRITE | |
| - name: write .env.production | |
| run: | | |
| cat << EOF >> .env.production | |
| NEXT_PUBLIC_API_BASED_URL = http://back-svc:8080 | |
| EOF | |
| - name: Login to Amazon ECR | |
| uses: aws-actions/amazon-ecr-login@v1 | |
| - name: Build and Push Docker image | |
| run: | | |
| docker build -t joyuri-frontend:latest . | |
| docker tag joyuri-frontend:latest 575108943098.dkr.ecr.ap-northeast-2.amazonaws.com/joyuri-frontend:latest | |
| docker push 575108943098.dkr.ecr.ap-northeast-2.amazonaws.com/joyuri-frontend:latest | |
| - name: Update kubeconfig | |
| run: aws eks update-kubeconfig --region ap-northeast-2 --name my-eks-cluster | |
| - name: Deploy to EKS (using latest tag) 🚀 | |
| run: | | |
| kubectl set image deployment/frontend-deployment \ | |
| frontend-container=575108943098.dkr.ecr.ap-northeast-2.amazonaws.com/joyuri-frontend:latest \ |