Publish only on GitHub tag/release

To unify the deploy process across my organization’s branching structure, I would like a Netlify site to only have the changes published with a new GitHub release. I thought about doing this with the Netlify CLI using GitHub Actions to trigger a deploy on release – however, there is currently no way to only publish sites with a GitHub release, as leaving autopublish on would publish all commits to master, and there does not seem to be any way in the UI to disable automatic builds from master.

Two things would help with this:

  1. The ability to turn off automatic builds for the production branch, while still leaving autopublishing on
  2. A way to mark a certain commit/git tag as publishable with the Netlify CLI, so it would automatically publish that revision once the build finishes (or if it has already finished)

You can accomplish #1 already, @yunyu - we can make sure that your code triggers no automatic builds, but is still connected to git. Then you could make some extra effort to trigger a build - e.g. via a special webhook that you hit only when there is a release - and then you can either let those builds be autopublished, or use the API to publish a new one.

Let me know if you’d like your site or sites converted to that behavior; it’s a 0-downtime database setting that I can put in place for you.

#2 I’ve added you to the open feature request we have, which says something like “make releases a selectable ‘event’ for Netlify builds - and thus, deploys”. We’ll follow up in this thread if we implement that.

We are also pretty close to releasing a new beta feature called build plugins that you can read about here, that gives you more control over how we build/deploy:

…which might be a more direct path to the result you request, since I don’t think we’ll implement that feature request very soon.

@fool Hello. I think we use a similar workflow to the one discussed here with tagged deployments, and I was wondering if the solution mentioned is still the best option.

I would like all of our deploy previews to automatically build as they do now, but I only want to deploy to production manually. I guess that means I want auto-publishing of the production branch off, but I would still like to be able to manually deploy to production, without turning auto-publishing back on each time.

Is that how the database setting mentioned above would work?

Auto-publishing doesn’t need to be turned on to manually publish a deploy. You can simply click on the publish deploy button and it should work. Is that not what you’re seeing?

I’m also curious if any new evolution on this topic has occurred. In our experience with building mobile apps, we have come to love the following deployment strategy:

PRs: Deploy preview builds
Commits to main branch: Deploy to a fixed “staging” URL
Creation of a Github Release: Deploys to the production URL

I’m still unclear if Netlify has an “easy” way to do this already. And if not, what would be the best way to go about setting this up in a more “advanced” way?

Hey @duro,

Unfortunately, there’s no easier way available at the moment. I’m not sure what you mean by more advanced way, could you please clarify?