Triggering Netlify from a specific GitHub branch

Hey cbetta

You could setup a netlify function as your webhook endpoint.

In that function, you can check the github webhook payload and verify the branch is the correct one and then ping the netlify build URL if it matches.

Here is a function example that is triggering builds from dropbox https://github.com/chaseadamsio/chaseonsoftware/blob/3f181cd88417dd002c90fff36afb75fe46357e50/src/_netlify-functions/dropbox-webhook.js#L31-L43

You can alter that code to instead receive the github webhook post. In your github webhook setting you would point to the netlify function URL (something like mysite.com/.netlify/functions/function-name)

From Functions examples - Netlify Functions

1 Like