Deploying Jekyll with GitHub Actions, not Pages

Rachael Wright-Munn - May 23 '21 - - Dev Community

I built a Gem that embeds Twitch clips in Jekyll Sites! Unfortunately, I can’t use it, because I’m deploying using github-pages. So let’s change the deploy process. 😏

Why do we have to do this?

GitHub pages is where my site is hosted. They require you to add the gh-pages gem instead of the jekyll gem, and they lock the version of Jekyll at 3.9.0. They would have to rework how gh-pages interacts with GitHub servers to support Jekyll 4.0, and that would break all the 3.9 sites out there. They’ve decided not to upgrade instead.

They also don’t let you add random plugins. Only their allow list, and my baby Jekyll-Twitch isn’t on it.

So, what’s the plan?

Jekyll has shared a guide on deploying using GitHub Actions. We’ll need a github_pages.yml file in .github/workflows. This is going to trigger every time we push to main. It’ll call out to a jekyll-action created by helaili which deploys the static site on the gh-pages branch. The jekyll-action deprecates JEKYLL_PAT, so we should update their docs while we do this.

There’s some additional GitHub configuration necessary. First, the jekyll action needs a github token to push to the gh-pages branch, then GitHub needs to use the gh-pages branch instead of the main branch.

We’ll need to include a secret in our action to store the github token.

This was easier than I thought.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .