Automating post deployment

The problem

Publishing posts via hugo is slightly more manual than I'd like. The trigger for this post was "Can we automate this with Github actions?", but it turns out the solution was much simpler.


The setup for the initial deployment was described in this post.

For adding a new post or amendments to a post, the procedure is:

  1. Run the script.

  2. Commit and push the changes to the source repo.

  3. cd to public directory in source repo.

  4. git push to push to the built site repo.

My first throughs where whether we could automate steps 3 and 4 with Github actions? But I think a better approach is to modify the script - there's no need for anything after step 1 to be manual.


After writing or amending a post, commit the changes locally and then run the modified The original version of the script came from the hugo docs; the description and comments implies that the new behaviour is what was intended for the script? Either way, this version works for me now, while previously I had to perform the extra steps.


It looks like the original script doesn't perform the git push stage if there's nothing to commit - e.g. if the commit was done manually. So it may be that separating the push into two steps isn't necessary, but if it ain't broke…

See also