# Triggering publish with a webhook

**URL:** <https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191>\
**Category:** Support\
**Tags:** building, deployment\
**Created:** [October 14, 2019, 7:32pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191 "2019-10-14T19:32:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rosslh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/rosslh/32/3475_2.png) [@rosslh](https://answers.netlify.com/u/rosslh)\
**Post date:** [October 14, 2019, 7:32pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/1 "2019-10-14T19:32:19Z")

</div>

Right now, this is how my master branch is deployed:

**If I enable auto publishing** :

- Push some changes to master
- Netlify deploys and publishes the branch ( **regardless of whether my checks passed** )
- My CI builds the branch and runs tests
- If the tests pass…
  - The Netlify deploy webhook is called
  - Netlify deploys and publishes the branch again

**If I disable auto publishing** :

- Push some changes to master
- Netlify deploys (but doesn’t publish) the branch
- My CI builds the branch and runs tests
- If the tests pass…
  - The Netlify deploy webhook is called
  - Netlify deploys but **does not publish** the branch

**This is what I want to happen** :

- Push some changes to master
- Netlify deploys (but doesn’t publish) the branch
- My CI builds the branch and runs tests
- If the tests pass…
  - A Netlify publish webhook is called
  - Netlify **publishes** the deployed branch

Is this possible?

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [October 16, 2019, 12:13am UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/2 "2019-10-16T00:13:24Z")

</div>

Bit of an odd workflow - do you really want us to build the preview and then rebuild it to publish, without any changes?

I’d suggest that instead of calling the webhook after your CI passes, you instead call an API endpoint to publish the existing deploy. Saves you $$ on build minutes too 😉

[Netlify API documentation](https://open-api.netlify.com/#operation/restoreSiteDeploy) is the “publish this deploy as production” call, and then if you want to be careful, you can make sure that autopublish is disabled again: [Netlify API documentation](https://open-api.netlify.com/#operation/lockDeploy)

---

<div class="post-metadata">

**Author:** ![FDX](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fdx/32/4642_2.png) [@FDX](https://answers.netlify.com/u/FDX)\
**Post date:** [December 5, 2019, 5:51pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/3 "2019-12-05T17:51:56Z")

</div>

I’m having a similar problem. I just need to deploy & publish using a webhook, not on push.  
To prevent deploying on push I set the production branch to a non existing branch. The problem is that the webhook doesn’t autopublish unless the branch is the production one.

Would be nice to have a querystring option for the webhook to force publish or a way to stop building on git push.

---

<div class="post-metadata">

**Author:** ![laura](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/laura/32/6274_2.png) [@laura](https://answers.netlify.com/u/laura)\
**Post date:** [December 6, 2019, 10:35pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/4 "2019-12-06T22:35:34Z")

</div>

Hi @FDX! Welcome to netlify community.

Yes, this is possible. If you use GitLab or Bitbucket, you can delete the Netlify webhook in the settings for your repo at your git provider. If you are using GitHub, this is a little more involved so let us know and we can help with that.

---

<div class="post-metadata">

**Author:** ![liukaren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/liukaren/32/5163_2.png) [@liukaren](https://answers.netlify.com/u/liukaren)\
**Post date:** [December 26, 2019, 6:59pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/5 "2019-12-26T18:59:23Z")

</div>

Hi Laura, I’m having the same issue where I’d like to only deploy and publish after CI passes, and I’m using Github. Is there any way I can disable the automatic deploy on push to master? I don’t see Netlify in my webhooks, since I’m using the Github App.

---

<div class="post-metadata">

**Author:** ![Dennis](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/dennis/32/34_2.png) [@Dennis](https://answers.netlify.com/u/Dennis)\
**Post date:** [December 27, 2019, 4:21pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/6 "2019-12-27T16:21:41Z")

</div>

Since the Github integration uses an app to manage the connections, there won’t be a webhook to remove. There is a setting that can be set on our side but this cannot be managed by you. If you would like me to set it anyways, let me know which site it is.

---

<div class="post-metadata">

**Author:** ![liukaren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/liukaren/32/5163_2.png) [@liukaren](https://answers.netlify.com/u/liukaren)\
**Post date:** [December 28, 2019, 4:55pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/7 "2019-12-28T16:55:25Z")

</div>

Yes, that would be great! On my team it’s two sites: upbeat-dijkstra-7703d5 and friendly-newton-ba6d5f.

---

<div class="post-metadata">

**Author:** ![Dennis](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/dennis/32/34_2.png) [@Dennis](https://answers.netlify.com/u/Dennis)\
**Post date:** [December 28, 2019, 7:05pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/8 "2019-12-28T19:05:47Z")

</div>

Done, automatic builds is no longer enabled on those two sites. You can manually trigger builds or using build hooks to start a build.

---

<div class="post-metadata">

**Author:** ![liukaren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/liukaren/32/5163_2.png) [@liukaren](https://answers.netlify.com/u/liukaren)\
**Post date:** [December 30, 2019, 4:25pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/9 "2019-12-30T16:25:36Z")

</div>

That worked like a charm! Thanks so much!

---

<div class="post-metadata">

**Author:** ![Fabien](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fabien/32/6057_2.png) [@Fabien](https://answers.netlify.com/u/Fabien)\
**Post date:** [January 14, 2020, 2:35am UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/10 "2020-01-14T02:35:44Z")

</div>

Hello!  
I am not sure if this the right place to ask, but I would like to deploy only after my CI tests pass, and I could do it using yarn deploy --site #my\_site\_id --auth #my\_token --prod for the production branch.  
I can’t find a way to do this for the develop and staging branch though.

Right now all I can find is 2 choices:  
1- Set automatic deploys, set branch subdomains and have my code deployed on the correct branch but ignoring my tests  
2- Disable automatic deploys and deploy my code to production after my tests pass, but no develop or staging subdomains.

Can you please tell me if there is a way to deploy programmatically to a specified subdomain (branch)?

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [January 14, 2020, 5:59pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/11 "2020-01-14T17:59:13Z")

</div>

Hi Fabien, can you please make a new post about this, and tell us your netlify name etc? thank you.

---

<div class="post-metadata">

**Author:** ![biancouver](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/biancouver/32/14211_2.png) [@biancouver](https://answers.netlify.com/u/biancouver)\
**Post date:** [August 4, 2020, 5:23pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/13 "2020-08-04T17:23:12Z")

</div>

Hi Dennis,

We are in the same situation on our side. We’d like to only trigger a build and deploy from our `master` branch once our CI have passed our tests. We are using a build hook to do so, but right now our site builds and deploy twice: once automatically when Netlify detects changes on the `master` branch, and a second time via our CI build hook once tests have passed.

The site is at: admiring-meitner-ad1875

Thanks for you help!  
Frank

> [@liukaren](#):
>
> Hi Laura, I’m having the same issue where I’d like to only deploy and publish after CI passes, and I’m using Github. Is there any way I can disable the automatic deploy on push to master? I don’t see Netlify in my webhooks, since I’m using the Github App.

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [August 6, 2020, 10:20pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/14 "2020-08-06T22:20:31Z")

</div>

No problem, just got that enabled for you! Please let me know if it doesn’t work as expected.

---

<div class="post-metadata">

**Author:** ![biancouver](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/biancouver/32/14211_2.png) [@biancouver](https://answers.netlify.com/u/biancouver)\
**Post date:** [August 6, 2020, 11:27pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/16 "2020-08-06T23:27:13Z")

</div>

Thank you so much, it works great!

---

<div class="post-metadata">

**Author:** ![neoms21](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/neoms21/32/14678_2.png) [@neoms21](https://answers.netlify.com/u/neoms21)\
**Post date:** [August 16, 2020, 12:40pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/17 "2020-08-16T12:40:51Z")

</div>

Hi,

My netlify username is neoms21 and I’m facing the exact same issue as people here. What I’m assuming that you have to make some setting on your end to stop my sites from auto-publishing on push but from a build hook. I’ve set up one of my repos to be deployed from ‘no\_deploy’ and then call the webhook to deploy. It builds fine and deploys the site to [master--xxxx.netlify-app.com](http://master--xxxx.netlify-app.com) but doesn’t publish.

Could you please enable that setting for me so that it publishes the site when I call the build-hook on master branch? Could you please do it on both of my sites?

Thanks  
M

---

<div class="post-metadata">

**Author:** ![jen](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jen/32/6044_2.png) [@jen](https://answers.netlify.com/u/jen)\
**Post date:** [August 19, 2020, 11:21pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/18 "2020-08-19T23:21:40Z")

</div>

Hey @neoms21, answered you over here 🙂 → [Triggering publish using build hooks - #3 by jen](https://answers.netlify.com/t/triggering-publish-using-build-hooks/20907/3)

---

<div class="post-metadata">

**Author:** ![shill](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@shill](https://answers.netlify.com/u/shill)\
**Post date:** [September 8, 2020, 10:32pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/19 "2020-09-08T22:32:49Z")

</div>

Hello @jen @fool, I am not sure if my issue was answered yet in this thread, but I think it was close.

I currently have neither my Wordpress CMS webhook, [GitHub - staticfuse/gatsby-toolkit: WordPress + Gatsby. Build, deploy & connect.](https://github.com/staticfuse/gatsby-toolkit), or github webhook auto-publishing onto my website. However, I would like to set the wordpress CMS webhook to auto-publish, whereas I would like the merge from github to not auto-publish. Is this possible with parameters? [Build hooks | Netlify Docs](https://docs.netlify.com/configure-builds/build-hooks/#parameters)

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [September 14, 2020, 10:01pm UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/20 "2020-09-14T22:01:05Z")

</div>

nope! You’ll need to implement that logic in either the [ignore script](https://docs.netlify.com/configure-builds/file-based-configuration/#ignore-builds) or in your build pipeline. We provide the `$WEBHOOK_*` environment variables during build:

> **[Build environment variables](https://docs.netlify.com/build/configure-builds/environment-variables/)**
>
> Identify environment variables available in the build environment, set your own environment variables, and use environment variables during builds.

… and even if you don’t build two different branches (which is the pattern my next link is about), you can use a similar pattern as we describe in this article around doing conditional builds based on that incoming build data, instead of based on the branch or commit type:

[https://answers.netlify.com/t/support-guide-conditional-build-deploy-behavior-for-context-branch-on-netlify/122](https://answers.netlify.com/t/support-guide-conditional-build-deploy-behavior-for-context-branch-on-netlify/122)

---

<div class="post-metadata">

**Author:** ![ctriolo](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ctriolo/32/21475_2.png) [@ctriolo](https://answers.netlify.com/u/ctriolo)\
**Post date:** [October 4, 2022, 12:38am UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/21 "2022-10-04T00:38:27Z")

</div>

> Since the Github integration uses an app to manage the connections, there won’t be a webhook to remove. There is a setting that can be set on our side but this cannot be managed by you. If you would like me to set it anyways, let me know which site it is.

Hi team! Can we also get this turned off for our GitHub connection for site: `f88acd47-7f30-460f-9d6d-2109f0f523dc` We would like to have Netlify build our site but ONLY from a build hook and not on push.

Do let me know if there is a better way to do this these days, but my team and I were a little stumped here! Thank you!

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [October 9, 2022, 11:35am UTC](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191/22 "2022-10-09T11:35:28Z")

</div>

Hey @ctriolo,

This is done. Sorry about the delay.

There’s still not better way to do this unfortunately.

[Next page](https://answers.netlify.com/t/triggering-publish-with-a-webhook/4191.md?page=2)
