Your First GitHub Actions Workflow

GitHub Actions automate tasks triggered by events in your repository.

How it works

A workflow is a YAML file in .github/workflows/. It defines jobs that run on GitHub's servers when a specific event occurs (push, pull request, schedule, etc.).

Create your first workflow

yaml
# .github/workflows/ci.yml
name: CI

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

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          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

Key concepts

**Triggers (on)** — What starts the workflow: push, pull_request, schedule, workflow_dispatch (manual).

Jobs — Groups of steps that run on a virtual machine. Jobs run in parallel by default.

Steps — Individual tasks. Can use pre-built actions or run shell commands.

Runners — The machines that execute jobs. ubuntu-latest, macos-latest, windows-latest.

Push the YAML file to .github/workflows/ and GitHub will automatically run it on the next push.