milliHQ / terraform-aws-next-js

Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.
https://registry.terraform.io/modules/milliHQ/next-js/aws
Apache License 2.0
1.47k stars 151 forks source link

Dynamic Routes like [id].tsx doesn't be update in my github action #370

Open andrenjdev opened 2 years ago

andrenjdev commented 2 years ago

Hi Everyone,

I'm configuring a github action to update our frontend. This is github action's code:

name: Staging CI
on:
  push:
    branches:
      - 'staging'

env:     
  S3_BUCKET_URI: 's3://###'
  NEXT_PUBLIC_BASE_URL: "###"
  CDN_DISTRIBUTION_ID: "####"

jobs:
  build:
    #if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'staging'
    name: Deploy Website
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v1
        with:
          node-version: 16
      - run: npm install -g yarn
      - run: npm install npm@8.5.4 -g      
      - run: npm i --save-dev tf-next
      - run: yarn tf-next build
      - 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: us-east-1
      - run: aws s3 sync .next-tf/ ${{ env.S3_BUCKET_URI }}

It works well, but it breaks each route with a dynamic parameter like this: [id].tsx.

I'm using this version:

source = "milliHQ/next-js/aws"
version = "0.13.2"

EDIT: I found this: Dynamic routes Dynamic routes in Next.js need a server to render the corresponding HTML. That includes pages that are dynamically rendered (e.g. with data from a database) or use a dynamic parameter in their path (example.com/blog/[postId]) where the final paths could not be calculated at build time.

So I think I have to update lambda manually?

If I update with the command terraform apply everything works well but with github action it can't find some files on the dynamic routes. How can I fix it?