Having trouble deploying a monorepo build artifact from a GH action

PLEASE help us help you by writing a good post!

  • Netlify site name: I have 2 sites, both pointing at the same app source code (with different environment variables) dx-web-poc-eaus and dx-web-poc-etus

I am trying to hook up manual continuous delivery via a Github action to deploy a build output to my Netlify sites. In my GH action, I am using the Netlify CLI to deploy my output. The code that I’m using, after running setting my node version and running npm ci is as follows:

npm install --global netlify@latest
          npm run build
          netlify deploy \
            --dir .next \
            --filter new-nextjs-boilerplate
            --site ${{ secrets.NETLIFY_SITE_ID_ETUS }} \
            --auth ${{ secrets.NETLIFY_AUTH_TOKEN }}

where build triggers my build script, new-nextjs-boilerplate is the name of the app in my monorepo, I have set a secrets.NETLIFY_SITE_ID_ETUS variable which coincides with the site id of one of my sites that I see in the netlify console, and secrets.NETLIFY_AUTH_TOKEN points to a personal access token that I have created in netlify.

Running this command locally works as expected, and uploads my build files to my netlify site. When I run this through the GH action runner however, I see the following before the whole process errors:

Logging into your Netlify account...
Opening https://app.netlify.com/authorize?response_type=ticket&ticket=bf694a53d9af4691ef32fafa7bcb8b1b
- Waiting for authorization... (I need to click the above link in order to approve the run, once done the following lines output to the console)
You are now logged into your Netlify account!
Run netlify status for account details
To see all available commands run: netlify help
This folder isn't linked to a site yet
? What would you like to do? (Use arrow keys)
❯ Link this directory to an existing site 
  +  Create & configure a new site

I’d love some help on what I might be doing wrong here.

The correct command is:

netlify deploy --build --filter new-nextjs-biolerplate

If site and auth is not being passed correctly, you should check your GitHub Actions side of things why that would be happening. I’d advise setting the site ID variable with the name NETLIFY_SITE_ID so you don’t have to manually pass it to the CLI. CLI automatically detects NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID variables as long as they exist.