All Collections
Author Help
Setting up webhooks if you're using Leanpub's GitHub writing mode for your book
Setting up webhooks if you're using Leanpub's GitHub writing mode for your book

Keywords: webhooks, GitHub, how

Leanpub Support avatar
Written by Leanpub Support
Updated over a week ago

Leanpub lets you use webhooks to trigger a preview or a publish event whenever you push to your GitHub repository, if you're writing your book using our GitHub writing mode.

[Update November 29, 2021: Please note that we recently learned that when you set up a preview or publish webhook in GitHub, that actually triggers the action on Leanpub! So, currently, you should not set up a publish webhook until you're actually ready to publish your book.]

First, go to the Webhooks page for your book here:

https://leanpub.com/YOUR_BOOK/help/webhooks

...making sure to replace YOUR_BOOK with your book's unique web address.

You can also navigate to this page from your book's Overview page:

On that page, you'll find the Payload URLs you will need to copy into GitHub:

The top Payload URL is the one you will use if you want to trigger a preview every time you push to your repository; the bottom Payload URL is the on you will use if you want to publish a new version of your book every time you push to your repository.

NOTE: Do NOT show your API key to anyone! Treat it like a password.

(In the example above, we've blurred out the actual API key - do not show your API key to anyone!)

Select the URL you want to use and copy it.

Next, on GitHub, go to the repository for your book and click on "Settings":

Next, select "Webhooks":

This will take you to the Webhooks page for your repository. Now, click on "Add webhook":

(At this point, you may be prompted to enter your GitHub password.)

Paste the Payload URL you copied earlier into the "Payload URL" box:

(We've blurred out the actual API key again in this example.)

Next, click the "Add webhook" button:

You will now see that the webhook has been added to your repository:

That's it! The next time you push to your repository, that will trigger a preview of your book, or publish a new version of your book, depending on which option you chose. Please note that it may take a moment or two before you see the progress bar, indicating that the book generation process is under way.


If you have any feedback or questions about this article, please email the Leanpub team about it at hello@leanpub.com!

If you have any questions or thoughts on writing and self-publishing with Leanpub, please join our global community of authors in our Authors Forum here!

Are you interested in self-publishing, and creating your first Leanpub book? Here are some quick tutorials for our most popular writing modes: http://help.leanpub.com/en/articles/3088382-quick-walkthroughs-for-getting-started-on-a-leanpub-book

Are you looking for great deals on Leanpub ebooks, ebook bundles, and courses? Sign up for our Weekly and Monthly newsletter sales here!

Subscribe to our YouTube channel here: https://www.youtube.com/leanpub

Please subscribe to our YouTube channel here: https://www.youtube.com/leanpub

You can also follow Leanpub in lots of other places!

Did this answer your question?