Skip to content

Instantly share code, notes, and snippets.

@reedwane
Created August 25, 2023 19:13
Show Gist options
  • Save reedwane/9ca1ec1cf52110491c959b7ea4890044 to your computer and use it in GitHub Desktop.
Save reedwane/9ca1ec1cf52110491c959b7ea4890044 to your computer and use it in GitHub Desktop.
Nextjs deployment with github workflow to netlify using netlify cli and the nextjs runtime of netlify
## create a `netlify.toml` file in the root of your project directory with this config:
[[plugins]]
package = "@netlify/plugin-nextjs"
[build]
command = "npm run build"
publish = ".next"
## A sample workflow that works:
name: Deploy to Netlify Production on merge
on:
push:
branches:
- main
jobs:
deploy_and_publish:
name: 'Deploy'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Netlify CLI
run: npm install -g netlify-cli
- name: Install deps
run: npm install
- name: Deploy
run: ntl deploy --build --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PROD_TOKEN_SECRET }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_PROD_SITE_ID }}
you have to generate these from your netlify account:
- NETLIFY_AUTH_TOKEN
- NETLIFY_SITE_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment