DEV Community

Otto
Otto

Posted on

GitHub Actions in 2026: Automate Everything for Free (CI/CD Tutorial)

GitHub Actions in 2026: Automate Everything for Free (CI/CD Tutorial)

If you're still manually deploying code, running tests by hand, or forgetting to lint before commits — GitHub Actions is about to change your workflow completely.

Best part? It's free for public repos and generous for private ones (2,000 minutes/month on the free tier). In 2026, there's no reason not to automate your CI/CD pipeline.

What Is GitHub Actions?

GitHub Actions is a CI/CD platform baked directly into GitHub. You define workflows as YAML files that trigger on events (push, PR, schedule, etc.) and run automated jobs on GitHub's infrastructure.

No external tools, no separate accounts — everything lives in your .github/workflows/ directory.

Your First Workflow in 5 Minutes

Create .github/workflows/ci.yml in your repo:

name: CI Pipeline

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          pip install -r requirements.txt

      - name: Run tests
        run: |
          python -m pytest tests/ -v
Enter fullscreen mode Exit fullscreen mode

Push this file. Every commit to main or develop will now automatically run your test suite.

Real-World Workflows

1. Python Linting + Testing

name: Python Quality

on: [push, pull_request]

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
          cache: 'pip'

      - run: pip install flake8 pytest black

      - name: Check formatting
        run: black --check .

      - name: Lint
        run: flake8 . --max-line-length=100

      - name: Test
        run: pytest
Enter fullscreen mode Exit fullscreen mode

2. Auto-Deploy to GitHub Pages

name: Deploy to Pages

on:
  push:
    branches: [main]

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Pages
        uses: actions/configure-pages@v4

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: './dist'

      - name: Deploy to Pages
        id: deployment
        uses: actions/deploy-pages@v4
Enter fullscreen mode Exit fullscreen mode

3. Automated Security Scanning

name: Security Scan

on:
  schedule:
    - cron: '0 9 * * 1'  # Every Monday at 9am
  push:
    branches: [main]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run Trivy vulnerability scanner
        uses: aquasecurity/trivy-action@master
        with:
          scan-type: 'fs'
          scan-ref: '.'
          severity: 'CRITICAL,HIGH'
Enter fullscreen mode Exit fullscreen mode

4. Multi-Platform Testing Matrix

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python: ['3.9', '3.11', '3.12']

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - run: python -m pytest
Enter fullscreen mode Exit fullscreen mode

This runs 9 parallel jobs (3 OS × 3 Python versions) automatically. Finding compatibility bugs before users do.

Secrets and Environment Variables

Never hardcode credentials. Use GitHub Secrets:

- name: Deploy to server
  env:
    API_KEY: ${{ secrets.API_KEY }}
    DB_URL: ${{ secrets.DATABASE_URL }}
  run: |
    python deploy.py
Enter fullscreen mode Exit fullscreen mode

Add secrets at: Repository Settings > Secrets and variables > Actions

Workflow Tips That Save Hours

Cache Dependencies (3x Faster Builds)

- uses: actions/cache@v4
  with:
    path: ~/.cache/pip
    key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
    restore-keys: |
      ${{ runner.os }}-pip-
Enter fullscreen mode Exit fullscreen mode

Skip CI for Docs Changes

on:
  push:
    paths-ignore:
      - '**.md'
      - 'docs/**'
Enter fullscreen mode Exit fullscreen mode

Concurrency Control

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
Enter fullscreen mode Exit fullscreen mode

Cancels previous runs on the same branch when you push again — saves your free minutes.

GitHub Actions for Freelancers

Knowing Actions is increasingly a requirement, not a bonus, for freelance dev work:

  • Clients expect CI/CD as standard practice
  • You can charge extra for pipeline setup
  • Automated testing = fewer bugs = happier clients = referrals

I've added it as a skill on my Upwork profile and it's mentioned in nearly every client conversation now.

Next Steps

  1. Add a basic CI workflow to your next project
  2. Set up automatic deploys to GitHub Pages (free hosting)
  3. Explore the GitHub Actions Marketplace — 20,000+ actions
  4. Study reusable workflows for DRY pipelines

Freelancing and need to stay organized? I manage all my client projects, invoices, and revenue tracking with the Freelancer OS Notion Template — €19, one-time purchase.

What's your favourite GitHub Actions trick? Share it in the comments!

Top comments (0)