GitHub Actions Explained: Automation That Runs on Every Push

Introduction

Tests only help if they actually run. GitHub Actions is the automation built into GitHub: every time you push code or open a pull request, it can run your Jest tests, your Cypress suite, your build, and even your deployment — automatically, on GitHub's machines, with the results shown right on the pull request.

Workflows: YAML files that describe automation

Automation is defined in a YAML file inside your repository, at .github/workflows/, so it is versioned and reviewed like code:

name: Tests
on: [push, pull_request]
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

on says when it runs (every push and pull request), jobs says what runs (here, one job on Ubuntu), and steps are the commands: check out the code, set up Node 20, install dependencies, run the tests. A red X on a pull request now means "the tests failed" — visible before anyone merges, not discovered in production.

The ecosystem and the one secret rule

Thousands of ready-made actions exist in the Marketplace — setup for every language, deployment to every cloud, linting, security scanning — so most workflows are assembled, not written from scratch. But there is one rule that matters more than any other: never put secrets in a workflow file. API keys and tokens go in the repository's encrypted Secrets settings and are referenced as ${{ secrets.API_KEY }} — they never appear in logs or in the repository history. A leaked key in a public workflow file is compromised the moment it is pushed.

The honest trade

GitHub Actions is free for public repositories and generous for private ones, but minutes are metered — a heavy Cypress suite on every push adds up, which is why teams run fast tests on every push and the slow suite on a schedule or before release. It is also GitHub-specific: if a team ever leaves GitHub, workflows don't transfer. For most teams, that trade is worth it, because the automation lives where the code already lives.

Takeaway

Workflows are YAML in your repository, triggers decide when they run, and results appear on every pull request. Combined with the last two posts' tests, GitHub Actions closes the loop: code is tested automatically, every time, before it ever reaches users.

Comments

Popular posts from this blog

Swift Explained: Apple's Language for iPhone, Mac, and More

Flutter Explained: One Codebase, Every Screen

Go Explained: Simple Code That Runs Fast