[Support Guide] How can I disable automatic git deploys?

Hey @chrisworman-pela,
Is this a protected branch? If so, you may have to remove the check on the GitHub side. Even though these instructions are for enabling instead of disabling status checks, they will take you to the right place in GitHub where you should be able to remove netlify/pelacase/deploy-preview:

Let us know if that works for you!

Maybe this helps someone :man_shrugging: Instead of unlinking my Github repo (i.e. asking about that in my comment above), I ended up just doing:

// netlify.toml
  ignore = "/bin/true"

And calling a webhook from CI.

This isn’t ideal because although all automatic builds are cancelled (triggered as a result of a merge to master, in my case)…

  1. We can no longer manually deploy from the Netlify Site UI
  2. the build log is still cluttered w/ “cancelled” builds
  3. it’s also a misleading workaround which is unintuitive for my fellow engineers to follow and/or duplicate in other projects.

This leads me to really want a clean way to configure “Active Builds” without automatically building&deploying. I’m sure something like this is in the works, but wanted to just post this for posterity and the Netlify team’s visibility…

1 Like

Please remove the Gitlab association for the following API key


Hi, @bhagaban. The workflow being repeated in this topic is unlinking repositories from sites. For this workflow, we need the site API id, not the API key.

There are no sites with the API id you listed. You can find the API id under “Site Name” > Settings > General > Site information.

If you send us that id, we can unlink the repo. Note, this can also be done using the API. The Netlify CLI tool makes calling the API easier and it can be done like so:

netlify api unlinkSiteRepo  --data '{ "site_id": "1a997e22-11b7-44b7-945b-c062ef03c8bf" }'

You would need to replace 1a997e22-11b7-44b7-945b-c062ef03c8bf in the command above with the actual API id as found under “Site Name” > Settings > General > Site information. If you use Netlify CLI you can unlink the repo without the support team’s assistance.

If you would prefer for us to unlink the repo, again, please let us know the API id (not the key) and we will unlink it.

1 Like

Hello Netlify folks - this is something I’d also like, but there’s got to be a better way than this round about method of manually unlinking. Surely it would be simple to have the GUI set to “stop builds”, and still allow a specific webhook / API call to trigger. Eg a query param ?force_build=true (from Build hooks | Netlify Docs).

This would allow us to self manage this stuff.

Hello, somehow this flew a bit under the radar but we released the functionality to self-unlink via the UI in late February of this year. You can now take care of things yourself via this URL:

https://app.netlify.com/sites/[YOUR SITE NAME]/settings/deploys under manage repository:

Hello, I stumbled upon this thread as I was trying to block automatic deploys to both my production and staging branches until CI passes but I don’t want to block Deploy Previews.
My approach was similar to option 2, stop auto publishing and triggering a deploy with either a hook or the CLI from my CI pipeline but both seem to fail because of the lock; using the CI give a prompt to unlock deployments but I’m unable to respond to it in a CI context.
Screen Shot 2022-08-26 at 16.46.24

Any suggestions on how this could be accomplished?

Unless you’re deploying using netlify deploy --prod this should work fine. --prod is for production deploys.

This was done with a --prod flag, that’s what I want to deploy via the CLI or API only after the CI passes

One solution would be to use the CLI in the following way. If all CI tests pass:

  1. The CLI is used to make an API call to enable auto-publishing.
  2. The manual deploy is made using netlify deploy --prod.
  3. The CLI is used to make an API call to disable auto-publishing again.

Would that solution work for you? If so, please let us know and we’ll send examples of how to use the CLI to make these changes (steps 1 and 3 above).

I tried that approach but to lock/un-lock deploys via de API, I needed to either save the previous deploy id or find it every time since the endpoint requests it.
We ended up disabling builds completely and building on the CI to then deploy with the CLI with a mix of --prod and --alias flags based on the different cases

You could use our API to list deploys, too :slight_smile:

Hello all,

Is there any way of knowing if a deploy originated from a build hook from inside the ignore builds script?

With Vercel we have the deployment.meta.deployHookId which is very useful to short-circuit their Github App for preview environments deployment and take control over when to deploy when using Github Actions, but still benefitting from the Github App (comments in PR, deployment status in Github…).

Here’s what the ignore script looks like on Vercel: vercel-action/ignore-build.mjs at main · snaplet/vercel-action · GitHub

I’m trying to achieve the same thing on Netlify. :slight_smile:

This is a bit of a kludge but there is an environment variable which only exists when a webhook is used to trigger a deploy. The environment variable is named INCOMING_HOOK_BODY.

Even if no body is sent, the variable will be created for all webhook triggered deploys. If no webhook is used, the variable won’t be defined at all.

Will that meet your requirements in this case?

Yeah this could work, as far as I understand that endpoint, it returns a list of all the deploys but again I have to find in all of them the one that my site is “locked” too. Is there a way to filter the query to get just that one deploy id?

No, but filtering is not too difficult either:

const requiredDeploy = deploys.filter(deploy => {
  return deploy.id === '123' // check any condition that you need