Wyam, Github Actions and Locales

Published
Wednesday, 30 June 2021
Category
DevOps
Author
Andrew H

When creating this blog, I chose to use Wyam as a static site generator. Static site generators are convenient because they avoid the cost and security implications of running a content management site. There is less risk of the blog being compromised because of an unknown bug in the code that runs it, if there is no code!

As I launched the blog, I found I had a problem. Whilst Wyam worked very well locally, but once I automated the build and deployment, all of the blog posts were missing from the site. In my case, I automated the build using GitHub Actions. Looking at the output of the GitHub Action logs, it was reporting that the blogs were skipped because there was no Published metadata.

Here's the line from the log that first helped me to identify the root cause of the behaviour I was seeing:

Skipping file:///home/runner/work/<path and filename>.md due to not having Published metadata

It took me a few minutes, but soon I realised that this was likely to be a locale problem. I had entered the Published date in the British date format, and that format was not being recognised. It wasn't that the published date wasn't present, but that the date wasn't being recognised as a valid date in the locale under which the runner was executing Wyam.

The solution is relatively simple: add an extra step early in the workflow to change the locale to the one that would allow me to use British date format. I found details of how to change the locale on Stack Overflow https://github.com/actions/virtual-environments/issues/762

Here's the YAML for the step that resolved the problem for me:

      - name: Set locale to en-GB
        run: |
          sudo locale-gen en_GB.UTF-8
          sudo update-locale LANG=en_GB.UTF-8

If you don't use the American date format and you get the message "Skipping file:///home/runner/work/.md due to not having Published metadata" then think about changing the locale on the container that is running your action before you run the Wyam build. In my case, I set the locale as the very first step, so that the rest of the job runs under the locale I expect.

This may apply to other scenarios. It's worth considering whether the locale is tripping you up if you find a difference in the behaviour between a build action that you run on your local workstation and how it runs on GitHub.