GitHub Actions is a CI/CD tool built into GitHub. It lets you automate things that happen when you push code β run tests, build your app, deploy to production, send notifications, anything.
You define workflows in YAML files, and GitHub runs them on their servers for free (with limits).
How it works
Create a file at .github/workflows/test.yml:
name: Run tests
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
- run: npm test
Now every time you push code, GitHub spins up a fresh Ubuntu machine, installs your dependencies, and runs your tests. You see the results in the PR.
Key concepts
Workflow β a YAML file that defines what to automate. Lives in .github/workflows/.
Trigger (on) β what starts the workflow: push, pull_request, schedule, workflow_dispatch (manual).
Job β a set of steps that run on the same machine. Jobs run in parallel by default.
Step β a single command (run) or reusable action (uses).
Action β a reusable step published by the community. actions/checkout checks out your code, actions/setup-node installs Node.js.
Common workflows
Deploy on push to main:
on:
push:
branches: [main]
Run on pull requests:
on:
pull_request:
branches: [main]
Scheduled (cron):
on:
schedule:
- cron: '0 6 * * *' # Daily at 6am UTC
Manual trigger:
on: workflow_dispatch
Free tier
GitHub Actions is free for public repos. For private repos, you get 2,000 minutes/month on the free plan. Thatβs plenty for most projects.
When to use GitHub Actions
If your code is on GitHub, use GitHub Actions. Itβs the simplest CI/CD option because thereβs nothing to set up β no external service, no webhooks, no configuration. Itβs just a YAML file in your repo.
For the full syntax reference, see the GitHub Actions cheat sheet. See also: What is CI/CD?