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

Reading a Workflow

Top to bottom.

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

When you join a project, one of the best ways to understand how it's built and tested is to read its workflows. Let's practise on a real looking CI workflow, top to bottom, and say out loud what each part does.

Reading a Workflow
From the video: Reading a Workflow
  • Join a project
  • Read its workflows
  • Top to bottom

ci.yml

It's called CI. It runs on a push to main, and on every pull request. There's one job, test, on Ubuntu. First, it checks out the code. Then it sets up Python three point twelve. Then it installs the requirements. And finally it runs the tests with pytest.

.github/workflows/ci.ymlyaml
name: CI

on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install dependencies
        run: pip install -q -r requirements.txt
      - name: Run tests
        run: pytest -q

Three questions

Whenever you read a workflow, ask three questions. When does it run? Look at on. Where does it run? Look at runs on. And what does it do? Read the steps, in order. Those three answers tell you almost everything.

  1. When? on:
  2. Where? runs-on:
  3. What? steps:
Three questions
From the video: Three questions

Summary

To read any workflow, ask when, where, and what. On, runs on, and steps. Next, events, and the on key, in detail.

Key takeaways
  • When: on
  • Where: runs-on
  • What: steps
Next up: Events with on — what starts a workflow