Class 42 of 50 • DevOps & CI/CD

GitHub Actions CI/CD: Workflow Architecture, Events & YAML Syntax

Software engineering has evolved far beyond writing code locally. In modern engineering teams, every commit triggers automated testing, static security analysis, code linting, and cloud deployments. GitHub Actions is GitHub's built-in Continuous Integration and Continuous Delivery (CI/CD) platform.

GitHub Actions Pipeline Flow Diagram
Figure 42.1: GitHub Actions CI/CD Architecture — Trigger Events, Virtual Runners, Step Execution & Automated Deployment.

The 5 Core Concepts of GitHub Actions

  1. Workflows: Configurable automated processes defined by YAML files stored in your repository at .github/workflows/.
  2. Events: Specific activities that automatically trigger a workflow to run (e.g., push, pull_request, release, or scheduled schedule: cron).
  3. Jobs: A set of steps in a workflow that executes on the same runner virtual machine. Multiple jobs run in parallel by default unless dependencies (needs:) are specified.
  4. Steps: Individual tasks that run commands (run: npm test) or pre-built reusable actions (uses: actions/checkout@v4).
  5. Runners: Virtual machines provisioned on demand in the cloud (e.g. ubuntu-latest, windows-latest, macos-latest) to execute your jobs.

Your First GitHub Actions Workflow

Create a file at .github/workflows/ci.yml in your repository:

# .github/workflows/ci.yml
name: Continuous Integration

# 1. When should this workflow trigger?
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

# 2. What jobs should execute?
jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
      # Step 1: Check out repository source code onto the VM
      - name: Check out repository
        uses: actions/checkout@v4

      # Step 2: Install Node.js runtime environment
      - name: Set up Node.js runtime
        uses: actions/setup-node@v4
        with:
          node-version: 20.x
          cache: 'npm'

      # Step 3: Install dependencies cleanly
      - name: Install dependencies
        run: npm ci

      # Step 4: Run linter
      - name: Run code linter
        run: npm run lint

      # Step 5: Execute automated unit test suite
      - name: Run test suite
        run: npm test

Monitoring Workflow Runs

Once you commit and push this file to GitHub:

  1. Navigate to the Actions tab in your repository.
  2. Click on the running workflow to view real-time streaming console logs of each step!
  3. If all steps pass, a green checkmark appears next to the commit. If any step fails, GitHub emails you immediately with the exact terminal error output.

Explore Related Git & GitHub Tutorials & Next Steps

Strengthen your version control mastery by studying these connected classes:

Building Production CI/CD Pipelines

Implement multi-job build, test, Docker containerization, and cloud deployment.

Automated PR Status Checks

Configure workflows to run on pull_request events and block failing merges.

Enforcing Required Status Checks

Block branch merges until all GitHub Actions workflows report success.

Client-Side Hooks vs GitHub Actions

Understand defense-in-depth: linting locally with hooks + validating in CI.

Frequently Asked Questions (FAQ) - Student & Interview Review

Public repositories get 100% free, unlimited GitHub Actions minutes! For private repositories, free personal accounts receive 2,000 free runner minutes per month, and GitHub Pro receives 3,000 minutes.
`npm install` can update package dependencies and write to `package-lock.json`. `npm ci` (Clean Install) strictly installs the exact versions locked in `package-lock.json` and deletes any existing `node_modules/`, ensuring 100% reproducible builds across runners.
Yes! Using the open-source CLI tool called `act` (github.com/nektos/act), you can run your GitHub Actions workflows locally using Docker containers before pushing to GitHub.

Next Step in Your Git & GitHub Learning Path:

Advance your software engineering skills with the next topic in our synchronized curriculum.

Continue to CI/CD Pipelines → Previous: ← Git Automation Hooks | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!