nwtgck / actions-netlify

🚀 Netlify deploy from GitHub Actions
MIT License
332 stars 41 forks source link

Wich is the right publish-dir path to Nextjs? #832

Open lucasggmc opened 2 years ago

lucasggmc commented 2 years ago

I'm trying to deploy my app on Netlify, There is no problem during the deploy, but I don't know the right publish-dir to can see my home page.

image

image

nwtgck commented 2 years ago

Could you show me the source?

lucasggmc commented 2 years ago

That is my full .yml file

name: ci

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - name: Checkout repository!
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Setup Node
        uses: actions/setup-node@v1
        with:
          node-version: ^14.19.1

      - name: Install dependencies
        run: yarn --frozen-lockfile

      - name: Run Jest tests
        run: yarn test

      - name: Deploy to Netlify
        uses: nwtgck/actions-netlify@v1.2
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        with:
          publish-dir: './public'
          production-branch: main
          production-deploy: true
        timeout-minutes: 2
nwtgck commented 2 years ago

Thanks. The yaml doesn't seem to contain a build process. You need yarn build or something.

dbk91 commented 2 years ago

I think there are a few issues here.

  1. Usually the build directory is either .next/ if using next build or out if using next build && next export, so updating the publish-dir to one of those directories should get you closer to a solution.
  2. If you're planning on using a Next.js server runtime—which is the former of the build commands above—you'll need to have the Netlify + Next.js plugin

Having said that, I tried using this Github action to produce the Next.js runtime and it doesn't seem to be respecting it. Not sure if there is an option to include the build flag as a part of the process.

The equivalent command using Netlify Actions would be deploy --build.

gcb commented 2 weeks ago

I see most projects use three dirs for nextjs, e.g. https://github.com/leerob/next-self-host/blob/main/Dockerfile#L20 [public, .next/standalone, .next/static]

Also, the build step from https://github.com/netlify-templates/next-platform-starter plus this action with publish-dir: '.next/' doesn't seem to work, and that is the "official" nextjs template from netlify. Still haven't built locally to understand why.

Run nwtgck/actions-netlify@v3.0
  with:
    publish-dir: .next/
    production-branch: master
    github-token: ***
    production-deploy: true
    deploy-message: Deployed from  Action. 
    enable-commit-comment: false
    enable-pull-request-comment: false
    overwrites-pull-request-comment: true
    enable-github-deployment: false
  env:
    NETLIFY_SITE_ID: ***
    NETLIFY_AUTH_TOKEN: ***
Error: No files or functions to deploy