Steps and Running Commands
You'll learn how to break GitHub Actions jobs into individual steps and execute shell commands within them.
What Are Steps?
A step is the smallest unit of work in a GitHub Actions workflow. Each job contains one or more steps that execute sequentially on the same runner. Think of steps like individual instructions in a recipe—each one builds on the previous, and they must happen in order to produce the final result.
Using the run Keyword
The most fundamental way to execute commands in a step is with the run keyword. This tells GitHub Actions to execute shell scripts or CLI commands directly:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check disk space
run: df -h
- name: List files
run: ls -la
- name: Multi-line script
run: |
echo "Building application..."
mkdir -p build
echo "Build directory created"
How Steps Work
Each step runs in its own process but shares the same filesystem and environment with other steps in the job. Steps execute top-to-bottom, and if one fails (exits with non-zero code), subsequent steps won't run unless you configure error handling.
You can name steps for clarity, run single commands, or execute multi-line shell scripts using the pipe (|) character.
Practical Use Cases
Steps are where you actually do the work: compiling code, running tests, deploying artifacts, or calling CLI tools like kubectl, terraform, or docker.
Key Takeaway: Steps break jobs into granular, sequential tasks using the run keyword to execute shell commands and scripts—they're the building blocks where your actual CI/CD work happens.