Nextjs github actions deployment to netlify

112 Views Asked by At

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. NotFoundError

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): Log Working

Example with the CLI (code above) : Log not working

Any help would be appreciated, thanks in advance.

Already tried :

  • --build option on netlify CLI (with npm run build and next build)
  • remove the plugin in the netlify.toml since it can be auto-detected by netlify
  • using the nwtgck/actions-netlify@v2 package instead of the official from netlify
0

There are 0 best solutions below