Merge pull request #103 from hyoni-ch/docu/#94 #48
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 |