GitHub Actions Basics: Your First Workflow, 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/workflowsfolder at the top of a repository. - Event: the parcel arriving, something that starts a run:
pushwhen you push commits,pull_requestwhen a pull request is opened or gets new commits,scheduleat 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.
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.
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.
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.