Area 07 · Deployment · Concept 05 of 20

GitHub Actions

GitHub’s built-in CI/CD. Workflows are written in YAML.

01–10 · The basePhase 5 · Weeks 18–20≈ 1.5 hours

The idea

GitHub Actions runs workflows defined in .github/workflows/*.yml. A workflow has triggers (push, pull_request, schedule, manual), jobs that run on hosted runners, and steps that either run shell commands or use reusable actions from the marketplace.

Secrets live in repository or environment settings and are injected as environment variables. Environments (staging, production) can require approvals. For cloud deploys, prefer OIDC federation (short-lived credentials) over long-lived cloud keys stored as secrets.

Use caching for pip and Docker layers, and matrix builds to test several versions.

Why it matters

If your code is on GitHub, it is the fastest way to get CI/CD running, and it is what most portfolio reviewers look for.

Words to know

  • RunnerThe machine that executes a job.
  • OIDCLets workflows get short-lived cloud credentials without stored keys.

Try it without code

Read a real workflow

  1. Open a popular open-source repo’s .github/workflows folder.
  2. Identify triggers, jobs and secrets used.

Use it in code

Build and push a Docker image to GitHub Container Registry on main.

yaml
name: build
on: { push: { branches: [main] } }
permissions: { contents: read, packages: write }
jobs:
  image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: docker/login-action@v3
        with: { registry: ghcr.io, username: "${{ github.actor }}", password: "${{ secrets.GITHUB_TOKEN }}" }
      - uses: docker/build-push-action@v6
        with:
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
          cache-from: type=gha
          cache-to: type=gha,mode=max
PRACTICE · TICK IT AFTER THIS

Add a build workflow to your RAG repo that pushes an image tagged with the commit SHA.

Common mistakes

  • Printing secrets in logs.
  • Workflows with write permissions they do not need.

Go deeper