GitHub Actions: First Workflow to Production
GitHub Actions is the most-used CI/CD platform (700M+ workflow runs/month). Itโs built into GitHub โ no setup server needed.
Your first workflow
Create .github/workflows/ci.yml:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
Thatโs it. Push to GitHub โ CI runs on every commit.
Common patterns
Matrix builds
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, macos-latest, windows-latest]
Secrets
env:
API_KEY: ${{ secrets.API_KEY }}
Caching
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Deploy on tag
on:
push:
tags: ['v*']
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- run: vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }}
Reusable workflows
.github/workflows/deploy.yml:
on: workflow_call
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./deploy.sh
Other workflows can call this:
jobs:
deploy:
uses: ./.github/workflows/deploy.yml
Key takeaways
.github/workflows/*.ymlfor each workflow${{ secrets.X }}for secrets${{ matrix.X }}for matrix builds- 700M+ runs/month โ itโs the de facto standard