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

Sometimes your projects may really benefit from automatic deploys, sometimes they won’t. For such sites, you can create them entirely as manual deploys or using Netlify’s CLI. If you want to turn off automatic deploys from git for a site that was linked with a repository, there are three easy options. You can choose the option that works best with your workflow.

  1. We have a feature called Locked Deploys that you can use to 'pin' a deploy on your production URL.

    To turn on the lock feature from your Deploys page, click the Stop auto publishing button .

That’s it! Netlify will no longer autopublish any deploys at your production URL.

However, deploys will still be built and will be available for you to preview and manually publish
whenever you want. You can still see all of your deploys as usual on your Deploys page in our UI.

When you are ready to resume automatic deploys, just click the Start auto publishing button.

  1. If you no longer want to trigger deploys via git, you can remove the webhook created by Netlify from your repository’s webhook settings at your git provider. This is the way all GitLab and BitBucket repos are configured, and some legacy GitHub sites as well. And as long as you don’t remove our deploy key, you can then trigger a deploy some other way - for instance, by pushing the “Trigger deploy” button on the Deploys page in our UI, or via our API. Note that folks using the GitHub app won’t have this option!

    No deploy previews for pull requests are created when you deploy this way, FYI.

  2. Use GitHub checks to stop automatic deploys under certain conditions using the protected branches feature. This last option is what we use internally at Netlify. We set it up this way so we have a successful build, all of our tests finish, and we have a deploy preview to look at before merging. So if a check fails, you’ll see a red x and your site will not merge & deploy:

If you’ve never used GitHub checks before, GitHub has easy, step-by-step instructions on how to set them up.

Note: If you want to keep your Netlify site but permanently remove the link from your site to your git repo, please share your site’s API ID in this thread and ask us to remove the assocation. There isn’t a way to do this in the UI currently, but we are happy to do it for you.

2 Likes

Hey, it looks like option 2 is no longer possible for GitHub since Netlify moved to using a GitHub App instead of webhooks. Removing the the GitHub App would apply to all of a user’s GitHub repos integrated with Netlify.

Is there any update on removing the link to a repo from a site?

1 Like

I didn’t see the option I needed, so I decided to post my solution here in case somebody has a similar use-case.

I’m using a monorepo which currently contains two Netlify sites that need to be built & deployed if there is any change in the respective package. I want to let my CI decide which Netlify site to deploy, so I don’t want to enable automatic deploys from master. However I do want to keep the deploy previews from Pull Requests to master.

Option 1 in the original post doesn’t really work for me because it might build a site when it is not necessary and won’t publish my site if I trigger a build in CI. Option 2 does work completely either because the webhook is also responsible for reading pull requests.
However, you can customise the permissions of the webhook, and remove the " Pushes: Git push to a repository." permission to disable automatic master deploys, but keep pull requests builds and previews.

I’m not sure if this is the correct/best way to handle my case, so please let me know if you have any suggestions.

thanks for sharing your solution, @Und3Rdo9!

I’d like to keep the following site but disconnect it from Github permanently. Is replying here still the best way to handle?

site’s api id:
99151e56-3842-4042-b3db-84570a1d3cdf

Thanks

Hi @bwl! I just replied to your email. We can finish it up there! :slight_smile:

Hi Laura!

I moved to building my site on Gatsby Cloud and deploying to Netlify from there to avoid running into the 15 min build time time-out. Thus I’d like to stop Netlify’s automatic builds triggered by the GitHub app. In case I can’t do this myself yet, could you do that for me?

Maybe one question before you do, for peace of mind: What exactly does permanently mean? Permanently as in “please don’t change your mind every second day because we got stuff to do” or permanently as in “once unlinked, you won’t be able to relink this site to the GitHub repo ever again, until the end of time”?

My site’s API id: 53f66847-c5c4-4f62-abbe-6e078256f7b8

Thank you!

Hi @Richy! Welcome to netlify community.

Definitely more of the "please don’t change your mind every second day because we got stuff to do” variety :slight_smile:

You can relink any time.

Let us know if you want to proceed!

In that case, please proceed. :slightly_smiling_face: Thank you!

Just got that site unlinked from the repo for you!

1 Like

Hey, it looks like option 2 is no longer possible for GitHub since Netlify moved to using a GitHub App instead of webhooks. Removing the the GitHub App would apply to all of a user’s GitHub repos integrated with Netlify.

Is there any update on removing the link to a repo from a site?

I’m looking for an answer to this question as well.

How do we relink our sites once unlinked?

In the deploy settings

Hi, @root and welcome to the Netlify community site. :smiley:

The answer that @devotox gave is correct (and thank you for answering, @devotox). Go to Site Name > Settings > Build & deploy > Build settings and then click the “Edit settings” button to link a new repo to the site.

@Ygilany, the repo has been unlinked from that site. :+1:

Ah that’s my bad - I meant to ask how to re-enable automatic git deploys after they’ve been disabled. Is that possible through deploy settings?

Sure, @root. Both @devotox and I did answer this question. I’ll be happy to go into more detail though.

We are unlinking sites here so that people can still use manual deploys but stop deploys from occurring when a git push to the upstream repo happens.

So, if you want start deploying again for the git push events, just re-link the repo again (or a different repo if that is want you want to do). That is done at Site Name > Settings > Build & deploy > Build settings, then click “Link site to Git”.

I said the button was labeled “Edit settings” earlier but I was wrong. When no repo is linked it is labeled “Link site to Git”. Here is a screenshot to clarify:

I’m also not sure if you could instead be asking, “How to I enable auto-publishing again if I’ve locked deploys?”

If that is the question, the answer can be found at the link below:

Please do let us know if there are other questions.

Thanks for the clarification! I think I should have clarified myself, though - our site is already linked and has been linked, and so when I click into Build settings, I do see “Edit settings” and then details about the link that already exists. However, it appears that git push events to the specified branch do not actually trigger a rebuild since I had written in to have automatic deploys disabled for our site. How would I go about re-enabling automatic deploys after having written in to have them disabled? (Also worth nothing that auto-publishing is already enabled on our site, so that isn’t the issue.)

@jen could I get my site unlinked as well?

83eb0890-7d1f-4927-af5b-031966f1fddc

@iammatthias Yes, done!

And @ssijak, we agree, would be great to have this feature in the UI! There is an open feature request internally.

2 Likes

Does the unlinking + manual deploys method still allow Build Hooks to work? I want to only publish after a certain step of my CI (deploying new serverless functions) passes. I really wish there was an easier solution, but it seems that stopping auto publishing also disables Build Hooks, and then the build won’t automatically run

Currently I’m considering:

  1. stopping auto-publishing, but continuing auto builds
  2. From my CI environment, use env variables to parse what github commit hash is building
  3. If the branch is master, use the netlify CLI / API to contact the netlify GET /api/v1/sites/:site_id/deploys API to find the commit_ref that matches
  4. Use POST /api/v1/sites/:site_id/deploys/:deploy_id/restore to effective ‘restore’ aka publish that desired commit

Will this work? Does anyone know a better way?

I wish there was an analogous feature to Build Hooks that was essentially a Publish Hook (make a POST request to a URL to publish a build, while specifying parameters to specify which build)