TExcelTAD
Home › Release Engineering & CI/CD › GitHub Actions: Workflows & Triggers

GitHub Actions: Workflows & Triggers

GitHub Actions is the CI/CD system most open-source projects and many companies use, so the next lessons go through it in depth. The examples are YAML files that can't run on this site; they follow the current GitHub Actions documentation and use the current major versions of the official actions (actions/checkout@v7, actions/setup-node@v7, actions/cache@v6, actions/upload-artifact@v7, actions/download-artifact@v8). The ideas behind them run as models in the browser.

The vocabulary

Term Meaning
workflow a YAML file in .github/workflows/; one file = one workflow
event / trigger what starts it: push, pull_request, workflow_dispatch (a button), schedule (cron), release, workflow_call (called by another workflow) and many more
job a set of steps on one runner (fresh VM or container); jobs run in parallel unless they declare needs
step a shell command (run:) or an action (uses:): reusable code from a repository or the Marketplace
runner the machine: GitHub-hosted (ubuntu-latest, windows-latest, macos-latest, and specific images such as ubuntu-24.04, ubuntu-24.04-arm) or self-hosted
context / expression ${{ github.ref }}, ${{ matrix.os }}, ${{ secrets.X }}: values filled in before a step runs

A complete CI workflow

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

on:
  push:
    branches: [main, 'release/**']
    tags: ['v*']
    paths-ignore: ['docs/**', '**.md']
  pull_request:
    branches: [main]
  workflow_dispatch:            # a "Run workflow" button, optionally with inputs

permissions:
  contents: read                # least privilege for the GITHUB_TOKEN (see the security lesson)

jobs:
  test:
    runs-on: ubuntu-24.04
    timeout-minutes: 15         # default is 360
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0        # full history and tags: needed by git describe and release tools
      - uses: actions/setup-node@v7
        with:
          node-version-file: .nvmrc
          cache: npm
      - run: npm ci
      - run: npm test
      - name: Describe the build
        run: echo "version $(git describe --tags --always)" >> "$GITHUB_STEP_SUMMARY"

Details worth knowing:

  • actions/checkout fetches one commit by default (fetch-depth: 1). Anything that needs history or tags (version from git describe, changelog generation, commitlint ranges) needs fetch-depth: 0. git describe & Version Strings shows the failure.
  • $GITHUB_STEP_SUMMARY, $GITHUB_OUTPUT and $GITHUB_ENV are files: append key=value lines to set step outputs and environment variables for later steps, or Markdown for the run summary.
  • Pin the runner image (ubuntu-24.04) for release builds; ubuntu-latest moves to a new Ubuntu version on GitHub's schedule, which changes compilers and libraries under you.

Triggers and filters

Trigger Typical use Notes
push with branches CI on main and release branches combine with paths/paths-ignore to skip docs-only changes
push with tags: ['v*'] release builds path filters are not evaluated for tag pushes
pull_request CI for PRs runs on the merge commit; from forks, the token is read-only and secrets are unavailable
pull_request_target labelling, commenting on fork PRs runs in the base repository's context with secrets: never check out and run the PR's code in it
workflow_dispatch manual releases, re-deploys inputs: define a form
schedule nightlies, dependency checks cron in UTC; can be delayed at busy times; disabled after 60 days of repository inactivity in public repos
release (types: [published]) publish after a human publishes a GitHub Release the release must be created with a token other than GITHUB_TOKEN to trigger it from another workflow
workflow_call reusable workflows Reusable Workflows & Composite Actions

The last row hides an important rule: events caused by the GITHUB_TOKEN don't start new workflow runs (except workflow_dispatch and repository_dispatch). A release job that pushes a tag with the default token will not trigger your on: push: tags workflow. Either do the build in the same workflow (needs), or push with a GitHub App token.

How branch and path filters match

Filters use glob patterns where * matches anything except /, ** matches anything including /, and a pattern starting with ! excludes. Patterns are evaluated in order, and the last matching pattern decides. This model implements those rules and checks a few refs and file lists:

python · try it yourself
import re

def glob_to_regex(pattern):
    out, i = "", 0
    while i < len(pattern):
        if pattern.startswith("**", i):
            out += ".*"; i += 2
        elif pattern[i] == "*":
            out += "[^/]*"; i += 1
        elif pattern[i] == "?":
            out += "[^/]"; i += 1
        else:
            out += re.escape(pattern[i]); i += 1
    return re.compile("^" + out + "
quot;) def matches(patterns, name): result = False for p in patterns: # in order; the last match wins negate = p.startswith("!") if glob_to_regex(p.lstrip("!")).match(name): result = not negate return result branches = ["main", "release/**", "!release/**-experimental"] for ref in ["main", "release/1.5", "release/v2/hotfix", "release/2.0-experimental", "feature/login"]: print(f"branch {ref:<26} -> {'run' if matches(branches, ref) else 'skip'}") tags = ["v[0-9]*"] # GitHub's patterns support character classes too; this model treats [...] as a regex class for tag in ["v1.4.2", "v2.0.0-rc.1", "nightly-2026-01-15", "version-1"]: print(f"tag {tag:<26} -> {'run' if re.match('^v[0-9][^/]* , tag) else 'skip'}") paths_ignore = ["docs/**", "**.md"] for files in [["README.md", "docs/intro.md"], ["src/main.c", "README.md"], ["docs/img/logo.png"]]: ignored = all(matches(paths_ignore, f) for f in files) print(f"push touching {files} -> {'skip' if ignored else 'run'}")
branch main                       -> run
branch release/1.5                -> run
branch release/v2/hotfix          -> run
branch release/2.0-experimental   -> skip
branch feature/login              -> skip
tag    v1.4.2                     -> run
tag    v2.0.0-rc.1                -> run
tag    nightly-2026-01-15         -> skip
tag    version-1                  -> skip
push touching ['README.md', 'docs/intro.md'] -> skip
push touching ['src/main.c', 'README.md'] -> run
push touching ['docs/img/logo.png'] -> skip

Two behaviours to remember from the output: release/** reaches nested branches but release/* would not, and paths-ignore skips a push only when every changed file matches; one source file among the docs is enough to run CI.

Test yourself

A release job pushes tag v1.2.0 using the default GITHUB_TOKEN. Your on: push: tags: ['v*'] workflow doesn't start. Why?

  1. Tags never trigger workflows
  2. Events created by GITHUB_TOKEN don't trigger new workflow runs
  3. The pattern is wrong
  4. The tag must be lightweight

Does the branch filter release/* match release/v2/hotfix?

  1. Yes
  2. No: * doesn't match /; use release/**
  3. Only on pull requests
  4. Only with paths

Why is fetch-depth: 0 needed for release jobs?

  1. To speed up checkout
  2. Release tools need the full history and tags to find the previous release
  3. To fetch submodules
  4. To enable caching