Post/Code

HomeAboutUsesNow

Gatsby and Circle CI (Part 1).

My GitHub page runs on Gatsby, currently, I use a deploy task to push my published HTML pages to GitHub, this however, has lead to my repo being somewhat confused since the repo on GitHub is actually the published files, not the source.

In an attempt to resolve this, I have started experimenting with Circle CI as a build tool. Circle CI promises "power, flexibility and control" and the ability to automate from commit to deploy. Circle CI offers a generous unlimited amount of repos and users, with up to 1000 build minutes on 1 container and 1 concurrent job. Sounds great! That is more than enough for my use case.

Similar to Azure Pipelines, Circle CI uses .yml files to setup the necessary instructions for your pipeline. I worked from the default Node.js Circle CI configuration. More here.

On first pass, when importing my source into GitHub, I was greeted with numerous GitHub security warnings, many of them 'High', which was a little concerning! In order to resolve these, I updated Gatsby to the latest version. While this resolved the security warnings, it broke my Gatsby local Gatsby develop task.

After some digging around, I found that some of the older Gatsby versions were incompatible with the latest versions. Since I want to keep publishing posts on my blog, I did not want to sit with a broken blog while I migrate the site to a completely revamped Gatsby site. As a result, I downgraded Gatsby to the latest suggested version according to the installed dependencies. After some tweaking and upgrading some individual dependencies, I was able to get my local gatsby develop and build tasks working again!

Then it was back to Circle CI to build... which failed again! This time complaining about unresolved dependencies. Namely Gatsby CLI was looking for resolve-cwd (by the prolific Sindre Sorhus). I then added Gatsby CLI to my dev dependencies and tried again. To my delight, this resolved the issue and Circle CI was able to successfully install and build my Gatsby site.

Next up, sorting out the deployment!