Get the next live webinar in your inbox

One email a month: the upcoming live event + free recording access for subscribers. No spam, unsubscribe anytime.

Lesson 5 of 10 ~20 min
Course progress
0%

Introduction to GitHub Actions

Understand GitHub Actions fundamentals and CI/CD concepts

What is GitHub Actions?

GitHub Actions is a powerful CI/CD platform that allows you to automate workflows directly in your GitHub repository. From running tests to deploying applications, Actions streamlines your development process.

Why GitHub Actions?

Built into GitHub - No external CI/CD service needed
Event-driven - Trigger workflows on push, pull requests, releases, and more
Flexible - Use pre-built actions or create custom ones
Scalable - Run jobs in parallel across multiple environments
Free tier - Generous free minutes for public repositories

Key Concepts

1. Workflows

YAML files that define your automation process:

name: CI Pipeline
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run tests
        run: npm test

2. Events

Triggers that start workflows:

  • push - Code pushed to repository
  • pull_request - PR opened or updated
  • schedule - Cron-based triggers
  • workflow_dispatch - Manual triggers
  • release - New release created

3. Jobs

Independent units of work that run in parallel or sequence:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - run: npm run build
  
  test:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - run: npm test

4. Steps

Individual tasks within a job:

  • Actions - Reusable units (uses:)
  • Commands - Shell commands (run:)

5. Runners

Virtual machines that execute your workflows:

  • GitHub-hosted: ubuntu-latest, windows-latest, macos-latest
  • Self-hosted: Your own infrastructure

Your First Workflow

Create .github/workflows/ci.yml:

name: CI
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18'
          cache: 'npm'
      
      - name: Install dependencies
        run: npm ci
      
      - name: Run tests
        run: npm test

Workflow Anatomy

name: Workflow Name          # Display name
on: [push]                   # Trigger events
jobs:                        # Jobs definition
  job-name:                  # Job ID
    runs-on: ubuntu-latest   # Runner
    steps:                   # Steps list
      - uses: action@v1      # Use an action
      - run: command         # Run a command

CI/CD Benefits

Automated Testing - Every commit is tested
Consistent Builds - Same environment every time
Fast Feedback - Know immediately if something breaks
Deployment Automation - Deploy with confidence
Quality Gates - Enforce standards before merge

Best Practices

  1. Start Simple - Begin with basic CI, add complexity gradually
  2. Cache Dependencies - Speed up builds with caching
  3. Use Matrix Builds - Test across multiple versions
  4. Fail Fast - Stop on first failure
  5. Secure Secrets - Use GitHub Secrets for sensitive data

Next Steps

Now that you understand the basics, we’ll build real-world workflows for testing, building, and deploying applications.