Recently I tried Github actions to deploy some of my static sites, and I’ve been quite happy with its capabilities. Let me share my configs for different kinds of setups.

What is Github Actions

Github Actions is an embedded CI/CD pipeline of Github. You need to define the workflow files in yml files under .github folder in the repository root folder, and you can unleash its true power.

Its main benefit is that it’s a Github service embedded in, and you can use it for free until (at the time of writing) 2000 build minutes per month. More info about pricing here.

Create React App on Github Pages

Create React App is a popular starter project for react.js applications.

Example repo

The tricky part is that if you use your Github pages site without a domain, it will serve your site in a subpath, BUT by default, Create-React-App assumes you serve it from the root.

In package.json, you need to set the "homepage" property to the name of the repository, starting with a forward slash.

For example, in my asciiart-text site, I needed to add:

{
  "homepage": "/asciiart-text"
}

Hugo site on Github Pages

Hugo claims to be the fastest static site generator, and I can not agree more.

Example repo

I publish my blog to Github pages built with Hugo.

Gatsby Static site on Github Pages

Gatsby is an incredible static site generator based on react.

Example repo

There are different predefined workflows for many static site generators, and I found one for gatsby. It worked fine, but I could not make it publish from a subdirectory, though it said in the docs. I spent a little time investigating, only to figure that the owner did not release the last version, so I forked it and fixed it for me.

Disclaimer

I have no affiliation with Github, and I just wanted to share my experience and collect my configs for future reference.