GitHub Actions: The Good, the Bad, and the Ugly

Peter Kogan
4 min readDec 30, 2021

--

In late 2019, GitHub had finally released GitHub Actions, a long-awaited move by many developers and followers of the beta version.

To mark their 2nd anniversary, I’ve decided to check out the progress they’ve made.

So what are GitHub Actions and are they worth your time? I’ll try to answer these questions in this post.

What Are GitHub Actions?

I found out that the best way to learn about GitHub Actions is through examples. Let’s start with a code project of mine, the Mock Generator.

Actions are placed inside yml files in the .github/workflows folder. You may put several yml files and name them as you like.

Here is the beginning of continuous-integration-workflow.yml, which is responsible for the CI:

The name key is pretty obvious, and the on key indicates when to trigger this flow. I wanted it to be triggered every time I push new code into any of my branches.

The next section of the file is jobs, where you can put a list of jobs that comprise your workflow. Jobs are run in parallel.

Every job has properties like the operating system and the steps, which are sequential tasks.

For the first job, I used two existing actions to check out my code and perform file formatting. All I had to do is mention which actions to use (uses) and send them some arguments.

Pretty neat, right?

The automated tests are configured later on the same file:

This job runs parallel to the first job, on a combination of Python versions and OS versions to ensure compatibility and avoid regressions.

Here are some additional elements that are new to this example:

  • strategy: this allows you to run a matrix of combinations instead of a single version of your job. Extremely useful and powerful.
  • runs-on: ${{ matrix.os }}: using expressions instead of hardcoded values.
  • A couple of steps use run instead of uses: this way you can execute custom shell commands in cases where there is no suitable action out of the box.

This covers the basics of workflow and action definitions. If you want a more thorough understanding of the syntax of the workflow files, you can find it in the official documentation.

As I mentioned earlier, the CI workflow is executed on every push to the repository. The Actions tab in the GitHub repository shows both the currently running workflows and their execution history:

Select the desired workflow, execution, job, and step for more details and the console output:

Now that we have covered the basic usage of GitHub Actions, we can proceed to the conclusions.

The Good

GitHub now allows you to execute code.

For free. Yes, you get computing resources like CPU and memory at your disposal for free. Public repositories get 2000 minutes of CPU time every month, that’s over 33 hours.

In addition, you can use and share common code snippets in the GitHub Actions Marketplace. This saves time and it’s a cool way of collaborating with the huge GitHub community.

The Bad

Using code snippets of other people is not trivial at times:

  • The documentation is lacking for many snippets, making it harder to integrate.
  • Some actions don’t work well with others, and there is no way of knowing this in advance.

To make those points clear, let’s use an analogy of a mobile app store: imagine that you are looking for a Chess game. You download several Chess apps from the store, some of them fail to launch due to your phone’s version while some other apps require you to change your display settings so they can run.

The Ugly

The marketplace:

  • The search mechanism returns the actions in an assorted way: you often see niche actions before you get to see the most popular actions.
  • The marketplace does not indicate which actions are more mature than others, you have to try them out yourself.

If we continue the mobile AppStore analogy from before: after your bad experience trying to download a good Chess app, you decide to settle for Checkers and you find several Checkers apps, but you don’t know how to choose between them: there is no indication of the number of downloads and many Checkers apps don’t have screenshots/videos to show the game experience. You end up installing one app after another till you find something that is satisfying.

Wrapping Up

Despite its flows, GitHub Actions is a welcomed addition to GitHub, making it a one-stop-shop for both source control and CI/CD.

The platform behind it is very powerful and can be used to achieve a great variety of things.

Besides, you had me on free CPU :)

Why don’t you try it out and let me know what you think?

--

--