Why do I need this

TL;DR: So that I don't need to touch my codebase to publish a new blog post.

This is specifically for how my blog is set up. This blog uses GitHub issues as a CMS. One issue with a specific label in the GitHub repo corresponds to one blog post.

In a typical SSG Next.js site, a build is triggered when you push to a specific branch. But for this site's blog, my posts don't live inside the codebase. They are issues on the GitHub repo, so a Vercel deploy won't be triggered if I add a new issue.

What I did

So what I did was create a webhook for this GitHub repo, which would send a POST request to a specified URL whenever I make changes to an issue or create a new one. POST requests would be sent to an endpoint provided by Vercel. Vercel calls it Deploy Hooks

Complete walkthrough

  1. In your Vercel project, go to Settings > Git. The path will look like: https://vercel.com/<username>/<project>/settings/git. Under Deploy Hooks use the Create Hook form to create a new deploy hook. Copy the unique URL that's generated.

  2. In your GitHub repository, go to Settings > Webhooks. Now click on the Add Webhook button. The path will look like https://github.com/<username>/<repo>/settings/hooks/new. Now enter the following details:

    1. Paste Vercel's deploy hook URL that you copied earlier into the Payload URL text field.
    2. In the Which events would you like to trigger this webhook? field I chose, Let me select individual events, and Issue comments and Issues, and I left the rest of the checkboxes unchecked. Ensure the Active checkbox at the bottom is checked. image image
  3. That's it. Now, every time you add a new issue, a build will be triggered on your Vercel project. You can test that by modifying an existing issue or creating a new one.