Github CICD NextJS on Plesk

Github CICD NextJS on Plesk
Photo by Luca Bravo / Unsplash

On Plesk

  1. Create domain.
  2. Select NodeJS
  3. Select Temporary domain name
  4. Create SSL
  5. Domaindashboard > Get Started > NodeJS > Enable & restart
  6. Add Deploy keys in Git
  7. Restart app (See Node settings)
  8. Check Application Root & Document Root: /httpdocs
  9. Node Settings: npm install & npm build
  10. A .next-folder is created, change
    1. document root to /httpdocs/.next/static
    2. Application startup file to node_modules/.bin/next
  11. Check node_modules/.bin/next
program.command("dev", {

isDefault: true

})

program.command("start")

before

remove {isDefault:true} and paste it in program.command("start")

program.command("dev")

program.command("start", {

isDefault: true

})

after

  1. Go to git setting and copy webhook, paste in github.
  2. Hosting Settings > SSH access > /bin/bash

In git settings paste folowing deploy actions

rm -rf tmp
(PATH=/opt/plesk/node/22/bin:$PATH; npm install && npm run build &> npm-install.log &)
mkdir tmp
touch tmp/restart.txt

Trouble shooting

If it doesnt work, check for errors; Node settings "+ NPM INSTALL" & "RUN SCRIPT" > Build.

Eslint Error

Change .eslintrc.json;

{

  "extends": ["next"]

}

.eslintrc.json