A Lambda function that can be setup behind API Gateway for a GitHub Webhook to rebuild a Hugo blog
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a GitHub webhook to trigger a function that is responsible for building a Hugo blog. If you set this up on your GitHub repository, this function will get called on certain repository events which will trigger a rebuild of your Hugo blog.

This is based on this example from the Serverless framework.

So you set up this Lambda function behind an API Gateway endpoint and you give the HTTP endpoint to your GitHub Webhook. This function will then asynchronously call your other Lambda function (example here) that is then responsible for building your Hugo website. Why do we need to chain functions like this? Well, building a Hugo site could take some time and API Gateway functions are limited to 30 seconds. So we just use this function to kickoff the real work.

Environment Variables

Here are the environment variables you MUST set on this Lambda function.

Name Description Example
GITHUB_WEBHOOK_SECRET The secret you configured on your GitHub webhook asdfjkl
BUILD_FUNCTION The main function that is responsible for building your Hugo blog build-my-blog