AI Hints
CI/CD with GitHub Actions · Lesson 16 of 138

Your First Workflow

Hello, Actions.

⏱ 2 min read▶ Video at 18:10🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

Time to write a workflow. We'll start with the smallest useful one. When code is pushed, it prints a greeting, and a little information about the machine it runs on. No tests yet. Just enough to see every part working.

Your First Workflow
From the video: Your First Workflow
  • Write a workflow
  • The smallest useful one
  • See every part work

hello.yml

Name is the title shown on GitHub. On says which event starts it, here a push. Under jobs, we have one job, called greet. Runs on picks the runner, the latest Ubuntu machine. And steps is the list of things to do. The first step echoes a greeting, and the second uses a pipe to run two commands.

.github/workflows/hello.ymlyaml
name: Hello

on: push

jobs:
  greet:
    runs-on: ubuntu-latest
    steps:
      - name: Say hello
        run: echo "Hello from GitHub Actions!"
      - name: Where am I?
        run: |
          echo "Running on $(uname -s)"
          python3 --version

Running it locally

This course runs in a sandbox that isn't connected to GitHub. So we use a small helper called run steps. It reads a workflow, and runs its run steps on this machine, in order, like a runner would, and prints a log like GitHub's. The greeting appears, then the operating system, Linux, and the Python version.

Terminal
run-steps .github/workflows/hello.yml
Workflow: Hello  (event: push, branch: main)
Job: greet
  ✓ Say hello
      Hello from GitHub Actions!
  ✓ Where am I?
      Running on Linux
      Python 3.12.3
  Job succeeded

Summary

A workflow has a name, an event, and jobs with steps. Our first one greets us, and shows where it runs. Next, where workflow files must live.

Key takeaways
  • name, on, jobs
  • runs-on
  • steps with run
Next up: The Workflows Folder — .github/workflows