Continuous Integration runs tests automatically on every push. Continuous Deployment automatically releases passing builds to production. GitHub Actions implements both through workflow files stored in .github/workflows/.

A Basic CI Workflow

.github/workflows/ci.ymlyaml
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - run: npm ci
      - run: npm test
      - run: npm run build

Workflow Anatomy

  • on — triggers: push, pull_request, schedule, workflow_dispatch
  • jobs — parallel units of work, each runs on a fresh runner
  • steps — sequential actions within a job
  • uses — references a pre-built action from the marketplace
  • run — executes a shell command