We use @netlify/plugin-nextjs version 5.3.2 for a nextjs monorepo
We had this working until we created a new PR this morning and the build started failing with this error
“netlify: command not found”
Here is the content of the workflow
name: Deploy Preview
on:
pull_request:
branches:
- development
types: [opened, synchronize, reopened, ready_for_review]
jobs:
deploy-preview:
runs-on: ubuntu-latest
if: "!github.event.pull_request.draft"
strategy:
matrix:
app: [client, admin] # Names of the applications within the monorepo
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.3
- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: pnpm-cache
with:
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-${{ github.event.number }}
restore-keys: |
${{ runner.os }}-pnpm-
- uses: actions/cache@v4
id: next-cache
with:
path: apps/${{ matrix.app }}/.next
key: ${{ runner.os }}-next-${{ github.event.number }}-${{ matrix.app }}
- name: Install dependencies
run: pnpm install -w
- name: Set netlify build variables
id: netlify-config
run: |
if [ "${{ matrix.app }}" == "client" ]; then
echo "NETLIFY_SITE_ID=${{ secrets.NETLIFY_TRACE_CLIENT_SITE_ID }}" >> $GITHUB_OUTPUT
echo "NETLIFY_PREVIEW_URL=https://deploy-preview-${{ github.event.number }}--trace-client-v2.netlify.app" >> $GITHUB_OUTPUT
elif [ "${{ matrix.app }}" == "admin" ]; then
echo "NETLIFY_SITE_ID=${{ secrets.NETLIFY_TRACE_ADMIN_SITE_ID }}" >> $GITHUB_OUTPUT
echo "NETLIFY_PREVIEW_URL=https://deploy-preview-${{ github.event.number }}--trace-admin-v2.netlify.app" >> $GITHUB_OUTPUT
fi
- name: Build and Deploy the app
id: deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
NETLIFY_SITE_ID: ${{ steps.netlify-config.outputs.NETLIFY_SITE_ID }}
MESSAGE: "Deploy Preview #${{ github.event.number }}: ${{ github.event.pull_request.title }}"
run: |
netlify deploy --build --filter ${{ matrix.app }} --context dev --dir apps/${{ matrix.app }}/.next --auth $NETLIFY_AUTH_TOKEN --site $NETLIFY_SITE_ID --alias deploy-preview-$PR_NUMBER --message "$MESSAGE"
- name: Update PR with preview URL
uses: thollander/actions-comment-pull-request@main
with:
message: |
Trace ${{ matrix.app }} app deploy preview URL: ${{ steps.netlify-config.outputs.NETLIFY_PREVIEW_URL }}
comment_tag: execution-${{ matrix.app }}