🔥Let’s Do DevOps: GitHub Reuseable Actions — Theory, Matrix, Concurrency, Make it all Dynamic 🚀

Kyler Middleton
9 min readMay 31, 2023

This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!

Hey all!

I’ve been spending my whole work days playing with GitHub Actions to attempt to build templates and permit my developers to scale horizontally out with minimal code changes. There’s so many cool features I’ve been discovering, like reuseable actions and dynamic matrixes.

For this post, I want to talk about a project I completed recently — we have a Terraform Plan & Deploy Action that accepts an input for which environment to target. However, we have ~50 environments that could be targeted. Sometimes we want to call lots of them, or make sure all environments are up to date. That horizontal scaling is an excellent technical challenge.

The Orchestration layer sees 14 possible target environments, and is concurrently running Terraform Plan on all of them. This scales with zero effort to the current GitHub Matrix max of 128 targets

To build it, I created an Orchestration Action that finds all the potential target environments, uses substring or regex matching input (say you only want to target the dev- environments), and then concurrently executes Terraform Plan & Apply against all the environments you selected. It works incredibly well, and runs like ✨butter✨.

If you only care about the code, scroll all the way to the bottom, a GitHub Repo is linked there for you to copy the code and build it yourself!

Running Actions by Hand ✋

We’re going to cover a lot of ground here, so let’s start with some basic stuff we’ll build on. First of all, Actions are the automated pipelines that run on GitHub’s platform. They can do all sorts of stuff (they are magical ✨).

They initially were fully GitOps only — they were triggered based on pushes to a branch, or branches being merged together. However, that was quickly expanded to a few other ways to trigger pipelines — one of those ways is to kick it off by hand. It looks like this from the GitHub Actions page within a repo.

--

--

Kyler Middleton

DevNetSecOps, DevRel, cloud security chick. I will teach you, it’s unavoidable. She/Her 🏳️‍🌈🏳️‍🌈, INFJ-A, support the EFF!