'AWS serverless with nextjs Only deploy s3 and cloudFront

I have a question about AWS serverless with Nextjs.

I would like ask if I can deploy my build file(.next) only to s3 and coludFront when I trigger serverless

It seems like each time I deploy my application with below script, serverless do more things than I would like to do(only build and upload s3 and cloud front)

Thank you for advance. Have a good day:)

Here is my deploy script

#
# GitHub Action for Serverless NextJS production environment
#
name: Deploy prod-nextjs-starter

on:
  push:
    branches: [main]
jobs:
  deploy-prod:
    runs-on: ubuntu-latest
    steps:
      - 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: ap-northeast-2

      - uses: canastro/copy-file-action@master
        with:
          source: "serverless-prod.yml"
          target: "serverless.yml"

      - uses: actions/setup-node@v2-beta
        with:
          node-version: "14"

      - name: Install dependencies
        run: npm install

      - name: Generate Environment Variables File for Production
        run: |
          echo "NEXT_PUBLIC_UNSPLASH_API_KEY=$NEXT_PUBLIC_UNSPLASH_API_KEY" >> .env
        env:
          NEXT_PUBLIC_UNSPLASH_API_KEY: ${{ secrets.NEXT_PUBLIC_UNSPLASH_API_KEY }}

      - name: Serverless AWS authentication
        run: npx serverless --component=serverless-next config credentials --provider aws --key ${{ secrets.AWS_ACCESS_KEY_ID }} --secret ${{ secrets.AWS_SECRET_ACCESS_KEY }}

      - name: Download `.serverless` state from S3
        run: aws s3 sync s3://nextjs-starter-serverless-state-bucket/nextjs-starter/prod/.serverless .serverless --delete

      - name: Deploy to AWS
        run: npm run deploy

      - name: Upload `.serverless` state to S3
        run: aws s3 sync .serverless s3://nextjs-starter-serverless-state-bucket/nextjs-starter/prod/.serverless --delete


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source