Introduction
Back in October 2024, I wrote this blog post after running into with the official marketplace offering ‘Azure/static-web-apps-deploy@v1’
3 days ago, the GoHugo Foundation released a patch edition ‘0.139.5’ which caused some issues with the GitHub Action I initially created back in October.
The Problem
I should have kind of thought about this, based on Happy and Sad workflows, I assumed (rightly or wrongly) that for every release pushed by the amazing GoHugo team would contain the required binaries for Hugo. For example if we look at the previous release ‘0.139.4’ - we can see the hugo_extended files.
As you can see, the .5 release, does not have this required files, and at the time of posting (albeit it’ll now be fixed from this post 😉) I had only written the action step based on the “Happy flow” or that there would always be the required files there. But well, they. are. not.
The Fix
So while on CHristmas Leave this week 🎉 I’ve tuesday morning reworking the two github action files I created for ‘Linux’ and ‘Windows’ and also moved them to a Github Repository. In short it was only one step which needed to be “updated”
The first step, checks to see the latest release
|
|
No changes here are required, but the second step is where the fun starts. for context this is what the ‘v1’ version looked like.
|
|
From the above code snippet, you can see that I did’nt factor in anything going wrong ever. Which rightly or wrongly isn’t the best way to write code. Having thought about it over a coffee, the revised plan was the following.
Should the latest release not include hugo_extended_«hugo-release»_Linux-64bit.tar.gz tar.gz
downgrade to the next patch release and check again, for example v0.139.5 moves to v0.139.4
|
|
Wrap Up
In this update to the original post from October 2024, we’ve tackled an issue caused by the GoHugo Foundation’s release of version 0.139.5, which lacked the expected hugo_extended binaries. This led to a breakdown in the previously working GitHub Action setup, which relied on the assumption that the necessary binaries would always be available.
The solution involved adding error handling and fallback logic to the GitHub Action. By implementing a version-checking mechanism, the workflow now automatically downgrades to the previous patch version if the latest release doesn’t include the required files. This change ensures that the action remains resilient, even when unexpected releases occur.
The updated workflow steps include:
- Checking the latest Hugo release.
- Attempting to download the hugo_extended binary.
- If the download fails, the script will decrement the patch version and retry until a valid version is found or all options are exhausted.
This enhancement ensures that your Hugo-related GitHub Actions will remain functional, even when new releases don’t go as planned. It’s a simple yet powerful way to add error handling and make automation more reliable.
Finally, As promised if you wish to look at the code base and use it for yourself - please check out: https://github.com/builtwithcaffeine/bwc-github-actions