Deploy issue - Error: Site not found

I’m using netlify-cli to deploy a basic site. There is one static file and one function. I created a new site and set the env vars needed but deploy can’t find the site. It’s there in the UI:

https://enro.netlify.app

Here’s the step in the Github action:

      - name: Deploy using Netlify CLI
        if: ${{ env.deploy_enabled == 'yes' }}
        uses: netlify/actions/cli@master
        env:
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} 
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        with:
          args: deploy --site=./dist/site --functions=./dist/functions --prod 

You can see from the logs the env vars are set:

netlify/actions/cli@mister
  with:
    args: deploy --site=./dist/site --functions=./dist/functions --prod
  env:
    nodejs_version: 20.4.0
    deploy_enabled: yes
    NETLIFY_SITE_ID: ***
    NETLIFY_AUTH_TOKEN: ***

The deploy completed without error but the site is never deployed. The logs contain this error:

Error: Site not found. Please rerun “netlify link”

What did I do wrong?

Based on the information provided, This error typically indicates that the Netlify CLI is unable to locate the site specified by the NETLIFY_SITE_ID environment variable.

To resolve this issue, you can try the following steps:

  1. Confirm that NETLIFY_SITE_ID environment variable is correctly set in the GitHub Actions workflow,
  2. Double-check the value of secrets.NETLIFY_SITE_ID to ensure it matches the correct Netlify site ID.

If the above steps don’t resolve the issue, can try running the netlify link command manually in your local environment to link the site with your Netlify CLI setup. This command establishes a connection between the local project and the Netlify site, which should help resolve the “Site not found” error.

Thanks for the reply. I did what you said, copy and pasted the Site ID from the web UI site information page, to the existing github secret, saved it.

Re-ran the workflow, it completes without error, the site still didn’t get deployed and the same error is in the logs.

The link command is not appropriate as I’m running this from a Github action.

What’s going on? Why are deploys broken?

You’re specifying the site as an argument. This expects a site ID, not the path to your dist folder.

Netlify CLI deploy command

That was it, must have introduced an error while copying over the command from another project. Here’s what the arg option should have been:

args: deploy --dir=$dist_dir/site --functions=$dist_dir/functions --prod

It’s been very hectic where I am, compounded by having unbelievably slow git commit / git push commands (at times several minutes waiting). So you end up with too many browser tabs open etc, gets very confusing, and leads to errors like that.

Thanks for the extra pair of eyes.

Hi, thanks for writing in and sharing that detail with the community. I can see your site is live now. :slightly_smiling_face: