Private Hugo Repo to Public on Github

I was researching ways of moving to Hugo for my site generator. I looked at a few options and as part of this I came a cross a workflow in github that allows me to store my site in a private repo and then publish the site to a public repo without too much fuss.

You can find the action here

I use the basic example config with minor changes to match my GitHub details.

The basic setup is as follows

  1. Create a private repo. This can be anything except site name used in step 2.
  2. Create a public repo named username.github.io where username is your actual GitHub username.

My workflow

Basically I edit my content locally in seperate branch from master. When I am finished and want to publish my content. I merge my changes in to the master branch. I then push my commits to my private repo. This in turn triggers the workflow. The workflow then builds the site in a virtual machine provided by github. It then clears out the public hosting repo and copies over the new contents.

Things to note:

  • You will need to configure a Personal Access Token. The workflow I use has a simple guide on this.

See also