Skip to content

Update main.yml

Update main.yml #66

Workflow file for this run

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
# env:
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker build -t joyuri-frontend:$IMAGE_TAG .
# docker tag joyuri-frontend:$IMAGE_TAG 575108943098.dkr.ecr.ap-northeast-2.amazonaws.com/joyuri-frontend:$IMAGE_TAG
# docker push 575108943098.dkr.ecr.ap-northeast-2.amazonaws.com/joyuri-frontend:$IMAGE_TAG
# - 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:$IMAGE_TAG \