markjgsmith

Notes

15:11:00 +07:00

Improving Github Actions build times

Since I keep running out of Github build minutes I was thinking about ways to optimise the build. Looking at the github action logs, the obvious place that can be improved is getting nodejs installed and setup. The entire build/deploy/backup workflow takes approx 7 minutes. Installing nodejs takes around 3 minutes, and because I run seperate jobs for build, deploy and backup, I actually end up installing nodejs twice.

My first thought was that maybe there was a way to create a custom runner. i.e. instead of running the stock ubuntu image, create an image (docker?) with nodejs and perhaps all the modules I use in the static site generator, then use that to run the build. After doing about 30 minutes of googling it seems that's only possible if you are self hosting your own runners. I might be wrong about this, I'll beed to do some more research. Currently I'm stuck using hosted Github runners.

I noticed while searching that there are some caching actions that enable you to cache build artifacts between runs. The most popular of which appears to be cache. I'm already using setup-node which uses the cache action. There appear to be some caching options I could try, but doesn't seem like caching will improve things much because as far as I can tell it's already downloading a pre built nodejs version. I could be wrong.

Ideally I want the build to be under a couple of minutes. The actual website build of 17000 markdown files only takes around 45 seconds, so it's a bit ridiculous that the whole build and deploy takes 7 minutes. There has to be a way to optimise. #

For enquiries about my consulting, development, training and writing services, aswell as sponsorship opportunities contact me directly via email. More details about me here.