GitHub Actions: CI/CD Workflows From First Run to Secure Deployments · GitHub Actions Workflows: Triggers, CI and Matrices
Your First Workflow: Events, Jobs and Steps
Create a workflow file, understand how events, jobs, runners and steps fit together, and read a run in the Actions tab.
What you'll build
A first workflow that runs on every push, has two jobs, and prints information about the commit. You'll learn the vocabulary every other workflow uses.
The idea
GitHub Actions runs automation in response to things that happen in your repository. A workflow is a YAML file in .github/workflows/:
- An event (
on:) starts it: a push, a pull request, a schedule, a manual click. - A job is a group of steps that runs on one fresh virtual machine called a runner (
runs-on: ubuntu-latest). - A step is either a shell command (
run:) or a reusable action (uses:). - Jobs run in parallel by default. Steps inside a job run in order, and a failing step stops that job.
Commit the file, push, and open the repository's Actions tab to see the run, its jobs and each step's log. A workflow can only run on GitHub, so every example in this course is checked with actionlint, the standard workflow linter, and the output shows what the workflow would do.
The code
name: Hello workflow
on: push
jobs:
info:
runs-on: ubuntu-latest
steps:
- name: Show commit details
run: |
echo "Repository: ${{ github.repository }}"
echo "Commit: ${{ github.sha }}"
echo "Branch: ${{ github.ref_name }}"
tools:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: List the files
run: ls -la
Output
actionlint: no problems found workflow: Hello workflow triggers: push jobs, in the order they run: info: runs on ubuntu-latest | 1 step(s) tools: runs on ubuntu-latest | 2 step(s)
Run this on your computer — see “Get Started” for setup.
Because neither job has needs:, they start at the same time on two different machines. The tools job uses actions/checkout, since a runner starts empty and does not contain your code until you check it out.
Common mistakes
- Forgetting
actions/checkout. Without it the runner has no repository files. - Wrong folder or extension. Files must be in
.github/workflows/and end in.ymlor.yaml. - YAML indentation errors. Use spaces, never tabs; a single wrong indent changes the meaning.
- Expecting steps to share a shell. Each
runstep starts a new shell, so acdorexportin one step is gone in the next. - Editing on a branch but expecting a run elsewhere.
pushworkflows run from the pushed commit's version of the file.
Key points
- A workflow is YAML in
.github/workflows/, triggered byon:events. - Jobs run in parallel on separate runners; steps run in order.
runexecutes shell commands;usesruns a reusable action.- Check out the repository yourself with
actions/checkout. Further reading: GitHub Docs.
Practice questions
Why do two jobs without `needs:` not share files or environment variables?
Answer
They run in parallel on separate, fresh runner machines. To share data you use job outputs for small values or artifacts for files.
What does `actions/checkout` do and why is it usually the first step?
Answer
It downloads your repository's files onto the runner. A runner starts empty, so any step that needs your code must come after a checkout.
Open in the app to mark lessons complete, take notes and track your progress.