GitHub Actions: Your First CI Workflow
Set up automated tests on every push in under 10 minutes with a single YAML file.
GitHub Actions in 10 Minutes
GitHub Actions is a free CI/CD system built into GitHub. Every time you push, it can automatically:
- run your tests,
- build your Docker image,
- deploy to production.
Anatomy of a workflow
Place this file in your repo at .github/workflows/ci.yml:
name: CI
on: # when to run
push: { branches: [main] }
pull_request:
jobs:
test: # a job is a set of steps that run on one machine
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: yarn }
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test --coverage
The four building blocks
| Word | Meaning |
|---|---|
| Workflow | The whole YAML file. |
| Job | A group of steps on one machine (runs-on). |
| Step | A single command or a pre-built uses: action. |
| Runner | The virtual machine that runs the job. |
Adding secrets
Go to Repo → Settings → Secrets and variables → Actions and add AWS_ACCESS_KEY_ID. Use it as:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Beginner tips
- Cache dependencies with
actions/setup-node'scache: yarn— huge speed win. - Split slow jobs into matrix builds to run Node 18, 20, 22 in parallel.
- Use the Marketplace — someone probably wrote the action you need.
Real-world example
Push code → tests run in 2 minutes → if green, a second job builds a Docker image and pushes to ECR → a third job deploys to staging. All from one file, all free (for public repos).
Keep reading
You may also like
devops
Git Handbook – Quick Reference
A complete collection of Git commands and notes, covering setup, commits, branching, merging, conflicts, and advanced workflows. This handbook is designed as a simple, step‑by‑step guide for beginners and professionals to quickly learn and apply Git in real projects.
devops
Kubernetes Explained for Absolute Beginners
The clearest possible introduction to Kubernetes — what it is, why it exists, and the seven words you need to know.
devops
GitHub Actions: A Complete CI Pipeline
Lint, test, build, publish — a battle-tested workflow template.
Discussion (0)
No comments yet. Be the first to weigh in.