πŸ“ Tutorials
Β· 3 min read
Last updated on

What is GitHub Actions? A Simple Explanation for Developers


GitHub Actions is a CI/CD platform built into GitHub. It lets you automate things that happen when you push code β€” running tests, building your app, deploying to production, linting, generating docs, or anything else you can script.

Every time you push to a branch or open a pull request, GitHub Actions can automatically run your workflows on GitHub’s servers. No separate CI service needed.

How it works

You define workflows in YAML files inside .github/workflows/. Each workflow has triggers (when to run) and jobs (what to run):

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

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

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

This workflow runs on every push to main and every PR targeting main. It checks out your code, installs Node.js, installs dependencies, and runs your tests.

Key concepts

Triggers (on) β€” what starts the workflow: push, pull_request, schedule (cron), workflow_dispatch (manual), or even release.

Jobs β€” independent units of work that run in parallel by default. Each job gets a fresh virtual machine.

Steps β€” sequential commands within a job. Either run (shell commands) or uses (pre-built actions from the marketplace).

Actions β€” reusable building blocks. actions/checkout checks out your code, actions/setup-node installs Node.js. Thousands of community actions exist for deploying to AWS, sending Slack notifications, publishing to npm, etc.

Common workflow examples

Deploy to Vercel on push

name: Deploy
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: amondnet/vercel-action@v25
        with:
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          vercel-org-id: ${{ secrets.ORG_ID }}
          vercel-project-id: ${{ secrets.PROJECT_ID }}
          vercel-args: '--prod'

Lint and type-check on PRs

name: Quality
on: [pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: 'npm'
      - run: npm ci
      - run: npm run lint
      - run: npm run typecheck

Scheduled job (daily)

name: Daily cleanup
on:
  schedule:
    - cron: '0 2 * * *'  # 2am UTC daily
jobs:
  cleanup:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Running cleanup..."

Secrets and environment variables

Store sensitive values in repository Settings β†’ Secrets:

env:
  DATABASE_URL: ${{ secrets.DATABASE_URL }}

Never hardcode secrets in workflow files β€” they’re visible in your repo.

Pricing

GitHub Actions is free for public repositories. For private repos, you get 2,000 minutes/month on the free plan. Linux runners are cheapest; macOS runners cost 10x more per minute.

FAQ

Is GitHub Actions free for open source projects?

Yes, GitHub Actions is completely free for public repositories with no minute limits. For private repos, you get 2,000 minutes per month on the free plan, 3,000 on Pro, and 50,000 on Enterprise. Linux runners are cheapest; macOS runners consume minutes at a 10x rate.

How do I debug a failing GitHub Actions workflow?

Add ACTIONS_STEP_DEBUG as a repository secret set to true for verbose logging. You can also add run: env steps to print environment variables, use the tmate action to SSH into the runner for interactive debugging, or run workflows locally with the act tool before pushing.

Can I run GitHub Actions on my own servers?

Yes, using self-hosted runners. You install the runner agent on your own machine (Linux, macOS, or Windows), register it with your repository, and target it with runs-on: self-hosted in your workflow. This is useful for accessing private networks, using specialized hardware, or avoiding per-minute costs.

Learn more

Related: Git Cheat Sheet