I have a monorepo on Github that looks something like this:
.
├── custom-go-tool
├──|--------------- main.go
├── archetypes
├── config.toml
├── netlify.toml
├── content
├── data
├── layouts
├── static
└── themes
At the moment my site is built by Netlify using the build command hugo --gc --minify
and that part works fine.
What I need help with is how to run my custom-go-tool
before Netlify builds by hugo site because my tool creates a JSON file under static/data.json
that needs to be deployed for the site to work.
I have two questions I need help answering:
-
How do I get Netlify to run my Go tool before Hugo build?
a) Can Netlify compile a Go program and then run it?
b) Do I need to use GitHub Actions to build the Go program and then make it available to Netlify during the build? -
Once my Go program runs on Netlify and the JSON file gets generated pre-Hugo build, I’m wondering if it’s necessary to commit the JSON file to the GitHub repo to have a version history. Can this be done?
I’ve googled and thought about this but I could really use some advice on the best approach
Btw I thought about running the Go program locally before pushing to Github and then Netlify but that introduces the potential for human error which I would like to avoid by always having the JSON generated during building.