</>

Technology

GitHub Actions

Difficulty

Beginner

Interview Question

What is GitHub Actions and how does it work?

Answer

What is GitHub Actions?

GitHub Actions is a CI/CD and automation platform built directly into GitHub. It lets you automate workflows — build, test, lint, deploy, notify — triggered by events in your repository.

How It Works

CODE
GitHub Event (push, PR, schedule)
        ↓
Workflow file (.github/workflows/ci.yml) is triggered
        ↓
Runner (Ubuntu/Windows/macOS VM) is provisioned
        ↓
Jobs run (each job gets a fresh runner)
        ↓
Steps execute inside each job (shell commands or Actions)
        ↓
Results reported back to GitHub (pass/fail, logs, artifacts)

Key Concepts

CODE
Repository
└── .github/
    └── workflows/
        ├── ci.yml        ← runs tests on every push
        ├── deploy.yml    ← deploys on merge to main
        └── nightly.yml   ← runs regression at 2 AM

Your First Workflow

YAML
# .github/workflows/hello.yml
name: Hello World

on:
  push:
    branches: [main]

jobs:
  say-hello:
    runs-on: ubuntu-latest

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

      - name: Say hello
        run: echo "Hello from GitHub Actions!"

      - name: Show runner info
        run: |
          echo "OS: ${{ runner.os }}"
          echo "Branch: ${{ github.ref }}"
          echo "Commit: ${{ github.sha }}"

GitHub Actions vs Jenkins

FeatureGitHub ActionsJenkins
HostingGitHub cloud (free tier)Self-hosted
SetupZero — YAML in repoInstall + configure server
RunnersGitHub-hosted (free)Your own agents
Marketplace20,000+ Actions1800+ plugins
ConfigYAML in .github/workflows/Jenkinsfile / UI
Free tier2,000 min/month (public free)Free (self-hosted cost)

Components

  • Workflow — the YAML file that defines the automation
  • Event (trigger) — what causes the workflow to run
  • Job — a unit of work that runs on one runner
  • Step — an individual task inside a job
  • Action — a reusable step from GitHub Marketplace (e.g., actions/checkout@v4)
  • Runner — the VM/container where jobs execute
  • Artifact — files saved after a job (test reports, builds)
  • Secret — encrypted variables (passwords, API keys)

Follow AutomateQA

Related Topics