Course contents · Lesson 12 of 16

GitHub Actions Basics: Your First Workflow, Hands-On

GitHub Actions Lab · Lesson 12 of 16 · 11 min Hands-on

Your team agrees that every push gets tested, yet someone always forgets to run the tests. Let GitHub do it instead. This lesson covers GitHub Actions basics: you write a first workflow, push it to your own copy of the course labs, and read what GitHub did, step by step.

Six words for one standing instruction

GitHub Actions is the CI/CD service built into GitHub, one of the tools lesson 4 named. Its vocabulary maps onto the note on the fridge:

  • Workflow: the note itself, a YAML file (lesson 4's plain-text settings format) in the .github/workflows folder at the top of a repository.
  • Event: the parcel arriving, something that starts a run: push when you push commits, pull_request when a pull request is opened or gets new commits, schedule at set times, such as daily at 09:00 UTC.
  • Job: a group of steps that runs on one machine.
  • Step: one line of the instruction, either a shell command (run:) or an action (uses:). A job's steps run in order.
  • Runner: the machine that runs a job. On GitHub's own runners, each job gets a fresh virtual machine (VM), a whole computer simulated in software (see Virtual Machines vs Containers), so nothing is left from earlier runs.
  • Action: a reusable, packaged step, such as actions/checkout, which copies your repository onto the runner.

One execution of a workflow is a workflow run. The flowchart follows one from your push to the result. Notice step 3: every run starts on a brand-new machine, so step 4 must fetch your code.

Flowchart in three rows. 1, you run git push and a commit goes to GitHub. 2, GitHub sees the event because on: push matches. 3, a fresh runner starts, a new ubuntu-latest virtual machine. 4, check out the code, which copies your repository onto it. 5, run steps in order, each a command or an action. 6, does every step exit with 0, which means success? Yes leads to job passes, green tick. No leads to job fails, the rest skipped, red cross. Both lead to the status on the commit and in the Actions tab. Footer: every push repeats this on a new machine
The runner starts empty every time, so fetching your code is a step you write.

Step 6 is lesson 5's exit-code rule (see Automated Testing in CI): a command ending with anything but 0 fails its step, later steps are skipped, and the job, run and commit turn red.

Lab step 1: fork the labs and read hello.yml

A fork is your own copy of someone else's repository on GitHub; you can push to it, so your workflows run there. You need git, a terminal (macOS, Linux, or Git Bash or WSL 2 on Windows) and the GitHub CLI (command-line tool), gh, logged in with gh auth login.

On the lab map, purple steps happen on GitHub and cyan ones on your laptop.

Six numbered steps, purple on github.com and cyan on your laptop. 1, fork the labs, your copy of datsabk/course-labs on GitHub. 2, clone your fork, a copy on your laptop, then cd course-labs. 3, add the workflow, copying hello.yml into .github/workflows/. 4, commit and push with git push. 5, open the Actions tab, Hello workflow, the newest run. 6, read the log: open a job, then a step, and see your message printed. A dashed arrow loops from 6 back to 4 for the next change. Footer: steps 1 and 2 happen once; every later change is edit, push, read
Fork and clone once; after that, every change is the same loop: edit, push, read.

This command creates the fork, and --clone also downloads it to your laptop:

gh repo fork datsabk/course-labs --clone
cd course-labs

You should see ✓ Created fork with your user name, ✓ Cloned fork and a note about the default repository. If gh says you are not logged in, run gh auth login first.

Workflows don't run in a fork until you allow them. Open your fork on github.com and click the Actions tab; if GitHub shows a button to enable workflows, click it.

Now open course-labs/ci-cd-and-devops-fundamentals/01-first-workflow/hello.yml in your editor, or on GitHub:

name: Hello workflow

on: push

jobs:
  say-hello:
    runs-on: ubuntu-latest
    steps:
      - name: Check out the code
        uses: actions/checkout@v7

      - name: Say hello
        run: echo "Hello from GitHub Actions"

      - name: List the files
        run: ls

YAML is built from keys, names ending in a colon, each with a value. A line indented under a key belongs to it, and a dash starts one item in a list, here one step. The diagram labels every key.

The 16 lines of hello.yml with an arrow from each key to a label. name: Hello workflow, the name shown in the Actions tab. on: push, the event, start a run on every push. jobs:, the work, one or more jobs. say-hello:, a job ID you choose. runs-on: ubuntu-latest, the runner, a fresh Ubuntu virtual machine. steps:, run in order, top to bottom. uses: actions/checkout@v7, run a ready-made action. Both run: lines, run a shell command. Purple marks workflow keys, cyan job keys, green step keys. Footer: indent with spaces, never tabs
Indentation does the nesting: the workflow holds a job, and the job holds steps that run top to bottom.

Read it top to bottom: Hello workflow runs on every push. Its one job, say-hello, asks for a GitHub-hosted Ubuntu runner (GitHub decides which version ubuntu-latest means), and its steps check out the code, print a message and list the files.

@v7 is a movable tag, like the image tags of lesson 7; GitHub's docs call a full commit SHA the safest pin.

Lab step 2: push the workflow and read the run

GitHub reads workflows only from .github/workflows at the top of the repository, so the lab's copy does nothing yet. From course-labs, create that folder (-p also makes missing parents), copy the file in, commit and push:

mkdir -p .github/workflows
cp ci-cd-and-devops-fundamentals/01-first-workflow/hello.yml .github/workflows/
git add .github/workflows/hello.yml
git commit -m "add workflow"
git push

Git should report 1 file changed, 16 insertions(+), and the push should end with a line like main -> main. If the push is rejected with a message ending in without `workflow` scope, your login may not change workflow files: run gh auth refresh --scopes workflow, then gh auth setup-git, and push again.

On github.com, open the Actions tab and click Hello workflow in the left sidebar. A push run is titled with its commit message, so you should see a run called add workflow, numbered #1. When it finishes, it shows a green tick, and the same tick appears beside the commit on your fork's main page.

Open the run, then click the say-hello job. Its log lists six steps, each with a tick: Set up job (the runner prepares and downloads the action), your three steps, Post Check out the code (cleanup) and Complete job.

Expand Say hello. Its first line is the command (click it to see the shell, /usr/bin/bash -e {0}), then the output (trimmed):

Run echo "Hello from GitHub Actions"
Hello from GitHub Actions

Now expand List the files. You should see your repository's top-level names, such as README.md and ci-cd-and-devops-fundamentals. They are there only because the checkout step copied them.

Lab step 3: change the message and add a step

Edit .github/workflows/hello.yml, the copy, not the original: change the text after echo, then add this step at the end, indented like the others:

      - name: Print the date
        run: date -u '+%Y-%m-%d %H:%M UTC'

date prints the date and time; -u means UTC, and the text after + sets the layout. Save, then commit with -a, which stages every changed file git already tracks, and push:

git commit -am "change message, print the date"
git push

You should see run #2, titled change message, print the date, with a fourth step of your own. Say hello prints your new message, and Print the date prints something like 2026-11-30 14:05 UTC. Run #1 is unchanged: each run uses the file from its own commit.

If git push says Everything up-to-date, nothing was committed, usually because the file was not saved. Save it and commit again.

Common mistakes and how the Actions tab shows them

Each of these three looks different in the Actions tab.

Wrong folder: no run appears, and nothing reports an error. The file must sit in .github/workflows/ at the top of the repository, with a plural workflows and a name ending in .yml or .yaml; git ls-files .github lists what git has there. The same silence can mean Actions is still off in your fork.

Bad YAML indentation: a red run appears within seconds, with no job in it. Open it: GitHub says the run likely failed because of a workflow file issue and names the problem, such as You have an error in your yaml syntax on line 13. Indent with spaces, never tabs, and line each key up with its neighbours.

Missing on: trigger: the same red run, with a message such as No event triggers defined in `on`: the note never says when to act.

Check yourself

You pushed hello.yml, but the Actions tab shows no run and no error. What do you check, and why does GitHub stay silent?

Check that the file is in .github/workflows at the top of the repository and that Actions is enabled in your fork. GitHub looks for workflows only in that folder, so a file elsewhere is just a file.

You delete the checkout step and push. List the files passes but prints nothing. Why?

Each job starts on a fresh runner with none of your code, and only checkout copies it there. Listing an empty folder still exits with 0, so the step passes.

A teammate's workflow turns red seconds after every push, and the run contains no job. Is the problem in their tests or in the workflow file?

The workflow file. A failing test fails inside a job, after steps have run; a run with no job means GitHub could not read the file, and the run names the problem.