Article Image

GitHub Actions for Dummies

1st September 2022 By Adriano Martins

Explain to your grandparents what GitHub Actions are in 5 minutes. This is a topic that is getting thrown around more and more with the rise of Pull Request Automation, we have found out that even software engineers don’t fully understand what they are, but here’s a quick fix.

A Cooking Analogy

Whenever we feel hungry, we go into the kitchen and use a recipe to cook.

In this action, a series of things happened. The first one was the event that triggered us to go into the kitchen and cook a recipe - feel hungry. The second one was the decision of where to execute/run our recipe - the kitchen. And finally what steps to follow - the recipe.

All these decisions have been orchestrated by us and can be summarized in the action of Eat when hungry with the following characteristics:

  • Trigger event - feel hungry
  • Execute on - the kitchen
  • Execution steps - the recipe

GitHub actions work like this, but for GitHub repositories.

GitHub Actions

A GitHub Action is an automation (also called workflow), triggered by certain events, which will execute one or more jobs, on a specific machine (runner).

The core components are:

  • Event: anything that happens inside the GitHub Repository. The list is pretty extensive. It goes from when labels are created, pull requests opened, or even when an issue is commented. The action can also be scheduled.
  • Workflow: a workflow is triggered by an event and it’s comprised of one or more jobs run in parallel (that can also have dependencies between them).
  • Jobs: A job is a series of steps to be executed in order. Each step is either a shell script that will be executed or an action that will be run.
  • Runners: A runner is a server that runs one job at a time.

Github Actions— Everything You Need to Know to Get Started , by Ahmed Besbes

Let’s analyse a GitHub Action example: Run the linter on a pull request update in a deno project.

1name: Deno
4 pull_request:
7 test:
8 runs-on: ubuntu-latest
10 steps:
11 - name: Setup repo
12 uses: actions/checkout@v3
14 - name: Setup Deno
15 # uses: denoland/setup-deno@v1
16 uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
17 with:
18 deno-version: v1.x
20 - name: Run linter
21 run: deno lint
  • Event: Update a pull request
  • Jobs:
    • Check out the repository
    • Setup Deno
    • Run the linter
  • Runner: Linux machine

Do you want to know more? GitHub offers a pretty good documentation page on GitHub Action that’s actually pretty easy to understand. Check it out: Understanding Github Actions ↗︎.

But this is the subject of another For Dummies blog post.

Try Reviepad
Disrupting how software developers collaborate