Before diving into writing our first workflow, it's crucial to understand the fundamental building blocks of GitHub Actions. This terminology forms the basis of every automation pipeline you'll create. According to the official GitHub documentation, these components work together to execute complex tasks in response to repository events.
-
Workflows: A workflow is a configurable automated process defined by a YAML file in your repository's
.github/workflows
directory. A single repository can have multiple workflows, each designed to handle a different task, such as building code, running tests, or deploying to production. -
Events: An event is a specific activity in a repository that triggers a workflow run. The most common events are
push
(when code is pushed to a branch) andpull_request
(when a pull request is created or updated), but there are dozens of others, includingschedule
for timed runs orworkflow_dispatch
for manual triggers. -
Jobs: A job is a set of steps within a workflow that execute on the same runner. By default, jobs run in parallel. You can also configure jobs to run sequentially if one job depends on the output of another. For instance, a
build
job might need to complete successfully before atest
job can begin. The concept of breaking down workflows into jobs is a cornerstone of effective CI, as highlighted in Martin Fowler's seminal work on Continuous Integration. -
Steps: A step is an individual task that can run commands or an action in a job. Steps within a job are executed in order and can share data. A step could be as simple as running a shell command like
npm install
or as complex as using a pre-built community action to deploy your application. -
Actions: Actions are standalone commands that are combined into steps to create a job. They are the core building blocks of workflows. You can create your own actions or use actions shared by the GitHub community in the GitHub Marketplace. A prime example is the
actions/checkout@v4
action, which is used in almost every workflow to check out your repository's code onto the runner. -
Runners: A runner is a server that runs your workflow jobs. GitHub provides Ubuntu, Windows, and macOS runners, known as GitHub-hosted runners. You can also host your own self-hosted runners for more control over the hardware, operating system, and software environment. The choice of runner is critical for performance and cost management, a factor that industry leaders like Atlassian emphasize in CI/CD architecture planning.