Github Actions V2: Build and Deploy Jekyll

Oct 5, 2019
Tags: Jekyll Web Development GitHub Actions

Late last year—after I got my invitation into the beta of Github Actions—I wrote up a quick little action and workflow for building and deploying a Jekyll repo back to its gh-pages branch. Mostly I just wanted to see how actions worked. But, this was also a nice way to build a Jekyll site with my own custom gems and buildscripts while still keeping the enitre workflow on Github—which is my preference.

Well…when Github said beta, they meant beta. In August they overhauled the Actions API taking it to, what I suppose was alwyays its logical conclusion, a fully fledged continuous integration/continuous deployment service. Support for actions and workflows written against the old API ended last week. So…I’ve re-written my simple little action for the new API.

workflow example

Keep in mind that as Github says: ‘GitHub Actions is currently in limited public beta and is subject to change.’ I imagine things will still change quite a bit. The GITHUB_TOKEN for instance—an auth token scoped to the repository, for doing things like pushing changes to the repo using the workflow—has limited ability to initiate builds on Github Pages (unless it’s being used in a workflow in a private repository), which doesn’t really make any sense when you think about it. But, they’re working on it.


Dry The Rain

Dec 16, 2018
Tags: Music

“I will now sell five copies of The Three EP’s by The Beta Band”.

"If there's something inside that you want to say, say it out loud it will be OK"


My Favorite Things

Dec 16, 2018
Tags: Music

Do yourself a favor this year. Skip the clichéd Mariah Carey remakes. Throw those awful Michael Bublé CD’s in the trash. Avoid the whole “Baby it’s Cold Outsite” drama. Just listen to this.

iTunes Album Art for My Favorite Things

Wikipedia explains:

The famous track is a modal rendition of the Rodgers and Hammerstein song “My Favorite Things” from The Sound of Music. The melody is heard numerous times throughout, but instead of playing solos over the written chord changes, both Tyner and Coltrane take extended solos over vamps of the two tonic chords, E minor and E major, played in waltz time.

This track exists as a life affirming oasis amid the neverending desert of holiday muzack being piped into every square inch of the public commons this time of year. Coltrane offers an existential escape—a brief respite from the soul crushing weight of those consumer-driven cultural expectations that we call The Holidays.

Be kind to yourself—play it on repeat—breathe. Merry Christmas.


Using GitHub Actions to Deploy your Jekyll Site

Dec 1, 2018
Tags: Jekyll Web Development GitHub Actions

UPDATE: Github Actions API has been updated, See here for an updated version of what’s discussed below

A few weeks ago, I got invited into the limited beta for GitHub Actions. In case you’ve not heard of Actions before—it’s GitHub’s pitch for the future of continuous integration/deployment of GitHub repos. As has been said:

The future has arrived, it’s just not evenly distributed yet. –Apocryphal William Gibson

Is Actions the future? I don’t know, but after playing with the beta for a bit—I do think it’s pretty cool. Even for something relatively straightforward like building a Jekyll site—the immediate advanages are obvious.

  • Want to use those custom Jekyll plugins that GitHub Pages has always blocked? No problem.
  • Want to update your search index with newly built pages everytime you deploy? Sure thing.
  • Want to run some NPM scripts to compress, concatenate, autoprefix, ship, resize, slice, or dice any, some, or all of your assets? Errr…OK.
  • Want to do it all while staying on GitHub…for free? Let’s do this.

Setting Up Your Workflow

Once we have access to Actions we can start things off by adding a do-stuff.workflow file in a .github directory sitting in the root of our repository. Github includes a little visual editor you can use to setup your workflow, but I found this to be more trouble than it was worth. Essentially: our workflow needs to identify itself, indicate a trigger, point to an action, and include any secrets or environment variables the action will need.

workflow "Deploy Site" {
  on = "push"
  resolves = ["Build and Deploy Jekyll"]
}

action "Build and Deploy Jekyll" {
  uses = "BryanSchuetz/[email protected]"
  secrets = ["GITHUB_TOKEN"]
}

Building the Action

In the action directory we need a couple things:

  • Dockerfile We’ll use Docker to setup a container within which we can import ruby and jekyll and any other gems we’ll need to build our site.
  • Entrypoint.sh This is where the heart of our action lives. We’ll install all our Gem dependencies, build the site, initialize and setup Git, and then push all the site files back to the gh-pages branch of our repo.
  • README.md Explain what the action does. One of the nicer features of Actions is that creators can expose them in a public repo—so that other users can call them from their own workflows!

Action Log

Try it Out

As mentioned above, I’ve put this action in its own public repository so anyone can point to it and use it to build and deploy their own Jekyll site. Or, just have a look around and see how I’ve sructured things—I’m sure there are efficiences I could make—if you have any suggestions, please let me know.


Concatenate JS for Free with Jekyll

Apr 15, 2018
Tags: Jekyll Web Development

This one’s a stupid little trick, but I literally use it all the time, and I’m always surprised how novel people find it when I explain it to them. Basically: use Liquid includes in a bundle.js file, and let Jekyll smash all your .js crap together for you.

Jekyll will parse any file that has a YAML front matter block at the top of the file. So, just drop one of those suckers at the top of your JS file and include your scripts in the order you need them.

bundle.js:


---
---

{% include _vendor/turbolinks.js %}
{% include _vendor/isotope.js %}

//More Awesome JS Stuff Below

When Jekyll hits bundle.js it will grab your partials and drop them into the file right where they should be. You may still want to minify, etc.—though your vendor files are probably already ugly. This is a super simple, no overhead, low config way to concatenate all your js crap together—letting Jekyll do what Jekyll does best: parse files.

The Distress Signal is the personal blog of Bryan Schuetz. I've been complaining on the Internet since the 90s, AMA—dispatch your courier électronique.