Different Site ID on staging site (branch deploy)?

Hello, is it possible to get a different Site ID for staging branch (branch deploy site)? I am setting up the Netlify Dashboard Widget on Sanity and it asks for “apiId”. If I enter the original Site ID, the icon will not update after I click “Deploy” next to Staging site. If I click the one next to Live site, both icons will change.

Hi @Edison_Lu ,

A site ID, as you would guess, is unique to a site. For your purposes, I’d suggest deploying the other branch as an entirely different site, so you can use its own ID.

Hi Support,

Thanks for your reply. Your suggestion will work, but it defeats the purpose of Branch Deploy. I can try changing our current workflow if that’s the only way around it.

What is the best way to create a new staging site (connecting to the staging branch in the same repo & same sanity backend)? Please let me know if I am missing anything.

Thanks,
Edison

Hi, @Edison_Lu. Are you using this workflow below? If so, I do think you can use branch deploys and a single site at Netlify.

The src/dashboardConfig.js config there looks like this:

export default {
  widgets: [
      {
      name: 'netlify',
      options: {
        title: 'My Netlify deploys',
        sites: [
          {
            title: 'Sanity Studio',
            apiId: 'xxxxx-yyyy-zzzz-xxxx-yyyyyyyy',
            buildHookId: 'xxxyyyxxxyyyyxxxyyy',
            name: 'sanity-gatsby-blog-20-studio',
          },
          {
            title: 'Website',
            apiId: 'yyyyy-xxxxx-zzzz-xxxx-yyyyyyyy',
            buildHookId: 'yyyyxxxxxyyyxxdxxx',
            name: 'sanity-gatsby-blog-20-web',
            url: 'https://my-sanity-deployment.com',
          }
        ]
      }
    }
  ]
}

This shows a buildHookId property. Build hooks are branch specific. You would need make a second build hook for the branch you want to use and then add it to buildHookId property for the site in question.

The value for the buildHookId is the last path segment in the build hook URL. For example, if this is the URL for the build hook:

https://api.netlify.com/build_hooks/23e2d3e1cl212c589145a483

then the buildHookId is:

  • 23e2d3e1cl212c589145a483

This will allow you to trigger builds for specific branches with Sanity.

​Please let us know if that doesn’t work as promised or if there are any other questions.

Hi Support,

Yes, I am using the workflow that you mentioned. I created a ‘staging’ branch for staging site. The problem I am facing is the related to the ‘apiId’ (Site ID). The staging branch does not have a unique apiId so the deploy status won’t change after you click on the Deploy button on the Sanity dashboard.

I am thinking to create a separate site as staging, but I got an error related to “sanity login”:

You must login first - run “sanity login”

How can I solve this? Please suggest.

Thanks,
Edison

Hi @Edison_Lu

I’ve reached out on our helpdesk where you asked for help.

Let us continue the discussion there.

Cheers!