What Is GitHub Actions?

GitHub Actions runs automated workflows in response to events in your repository.

GitHub Actions is GitHub's built-in automation and CI/CD platform. When something happens in your repo — a push, a new PR, a release — Actions can run a workflow automatically.

The building blocks

  • Event — what triggers the workflow (e.g. push).
  • Workflow — a YAML file in .github/workflows/.
  • Job — a set of steps that run on one machine.
  • Step — a single command or reusable action.
  • Runner — the virtual machine that executes a job.
An event triggers a workflow, which contains jobs, which contain stepsEventWorkflowJobStepstriggershasruns
Event triggers a workflow, which runs jobs made of steps.

Example

Example · yaml
# .github/workflows/hello.yml
name: Hello Actions
on: push
jobs:
  greet:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Hello from GitHub Actions!"

When to use it

  • A team automates running tests on every push so broken code is caught before it reaches main.
  • A developer uses a GitHub Actions workflow to publish an npm package automatically when a new tag is pushed.
  • An operations team uses Actions to deploy a Docker image to AWS ECS every time a PR merges into main.

More examples

Minimal hello-world workflow

The simplest possible workflow: triggers on any push, spins up an Ubuntu runner, and runs a shell command.

Example · yaml
name: Hello World
on: [push]
jobs:
  greet:
    runs-on: ubuntu-latest
    steps:
      - name: Print greeting
        run: echo "Hello from GitHub Actions!"

Workflow with checkout step

Adds the checkout action to clone the repo into the runner, then installs dependencies and builds the project.

Example · yaml
name: Build
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install deps
        run: npm ci
      - name: Build
        run: npm run build

List available runner environments

Shows the three hosted runner operating systems available on GitHub Actions by running the same step across all three.

Example · yaml
jobs:
  info:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - run: echo "Running on ${{ matrix.os }}"

Discussion

  • Be the first to comment on this lesson.