GitHub Actions automates workflows directly in your repository. A common use case is Continuous Integration (CI): automatically running tests and linting on every push or pull request to catch errors before merging.
Git
Beginner
10 min read
GitHub Actions: Basic CI Workflow
Example
# .github/workflows/ci.yml
# This workflow runs on every push and pull request to main.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Build
run: npm run build