Automatically Triggering Deploys on Netlify with Submodules
One of my goals was to rebuild my site on Netlify whenever there was a new commit on a Git submodule that was included in the repository.
Unfortunately, Netlify does not natively provide this functionality. It only “watches” the main repository for new commits.
To overcome this limitation, I took the following steps:
- I accessed the Deploy settings on Netlify and navigated to “Build hooks.”
- I clicked on “Add build hook” to create a unique URL that could be used to trigger the deployment.
After saving the settings, I obtained a URL like https://api.netlify.com/build_hooks/UNIQUE_STRING
.
Next, I created a GitHub Action in the submodule repository to automatically trigger the redeployment:
1 | name: Trigger redeploy on Netlify |
To use the Netlify UNIQUE_STRING value, you need to add it as an Action secret in your repository’s Settings -> Secrets -> Actions.
After committing the action, the deployment process should start working seamlessly.
Tags: Netlify, Git submodule, GitHub Actions, Deployment triggers