Nextjs github actions deployment to netlify

Hello, I would like to deploy a Nextjs website (called enchanting-elf-d42f40 on netlify) using the CLI, through GitHub actions but for now, I’m still getting this error when I want to access it:

Page Not Found : Looks like you’ve followed a broken link or entered a URL that doesn’t exist on this site.

To do this I’m creating a new site on the netlify UI, linking it to my GitHub repository, but afterward, I’m disabling the builds since I want them to be triggered through the CLI.
My netlify.toml :

[build]
command = "npm run build"
publish = ".next"

[[plugins]]
package = "@netlify/plugin-nextjs"

My production.yml :

name: Build & Deploy to Netlify
on:
push:
branches:
- master
pull_request:
types: [labeled, opened, synchronize, reopened]
jobs:
build-deploy:
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js version from package.json
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
- name: Npm install
run: npm ci
- name: Build
run: npm run build
- name: Deploy to Netlify
uses: netlify/actions/cli@master
with:
args: deploy --prod --dir=.next
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TEST_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

No functions are created on the deployment logs on the netlify UI, there are only files that are uploaded. I also tested the —build option for the CLI but it changed nothing.

Example with no CLI deploy, the build is done through netlify UI on another site (everything works):

Example with the CLI (code above) :

Any help would be appreciated, thanks in advance.

Hi @software,

Thanks for reaching out!

Have you seen this section from the GitHub for the next.js runtime:

Deploying

If you build on Netlify, the Next.js Runtime will work with no additional configuration. However if you are building and deploying locally using the Netlify CLI, you must deploy using netlify deploy --build. Running the build and deploy commands separately will not work, because the Next.js Runtime will not generate the required configuration.

I also found this blog post that may help:

Let us know if you have any questions.

I encountered a similar error: where I build my site from github actions successfully, but then I visit the url and I get a blank(all white) page. I followed all the steps outlined by team netlify of Manually installing NextJs runtime from npm

Having encountered this error, I resoughted to manually run netlify CLI on my local computer to deploy my site. I however ran into this issue shown in below image

A sample deploy url with a blank white screen is here: https://668939c395ebaf4fe4699a4a--react-loading-indicators.netlify.app/

Based on your site, you don’t seem to be using Next.js, you’re probably using React or at least you were using in the past. You probably have left the index.html in public directory that’s causing this.

I successfully moved a react website to nexjs. And now I want to host the nextjs website. My dashboard correctly detects that my site is now a NextJs website though. Here is a peek of a successful deployment after re-running ntl deploy --build as shown in my dashboard. But the website is still blank(I mean the draft url)

Did you check what I suggested:

Yes I did check for the dangling index.html in public folder. And after removing it, now i was able to see content of my website rendered. Thanks