Blog Migration

Today I have successfully migrated my blog from Jekyll to Hugo! I got tired of dealing with Ruby and Gems. I found a blog post about combining GitHub Actions, Hugo and AWS S3 in order to host a static site. Now that it’s setup, it’s pretty nice! All I have to do is commit the new post to the main branch of the repo and everything else happens auto-magically!

Steps Taken

I was able to accomplish this task with the following steps:

  • Updated my Terraform repo to create an IAM user and policy in AWS for the GitHub Action that builds the site and deploys it. It needs to have permission to access the S3 container that serves my site and PUT and DELETE objects to/from the container.
  • Followed the instructions in the blog post mentioned above to configure Hugo for Deployment to S3 by adding a deployment section to the Hugo configuration detailing the S3 bucket information.
  • Finally, I configured the actual GitHub Action that builds the site with Hugo and deploys it out to S3. The Action’s configuration (shown below) is set to only run the action when the main branch of the repo is updated. This means that I can save my work in another branch and play with it there. Once I’m ready to publish my updates, I can then create a Pull Request against the main branch and the site will automatically be updated once I merge the pull request.

Notes

The only thing of note was that in my experience, I had to add the S3::DeleteObject permission to the policy that I created for the GitHub user based on the blog post, otherwise it wasn’t able to do any file cleanup and failed.

Outcome

This is potentially exciting. I may be able to update the site without having to use a computer. For example, I could use my iPad to make the changes that I need, and merge it into the repository. With my Jekyll setup, I had to generate the site from my computer and push the files up to the endpoint that was serving them. (I’m sure there was a way to obtain the same functionality with GitHub Actions for Jekyll, but I didn’t have the patience to figure it out.)

GitHub Action

For anyone wondering, here’s my .github/workflows/s3_deploy.yml file:

See also