Learning Hub
← DevOps & Infrastructure

CI/CD with GitHub Actions

10 min readΒ·Updated 2026-07-20

Automate testing and deployment with a GitHub Actions workflow.

GitHub Actions runs workflows defined in YAML files under .github/workflows/ whenever an event (like a push or pull request) fires.

A minimal workflow

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

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test

Add a deploy step

Only deploy from main

Gate the deploy job on the branch so pull requests only run tests:

deploy:
  needs: test
  if: github.ref == 'refs/heads/main'
  runs-on: ubuntu-latest
  steps:
    - run: npm run deploy

Secrets

Store deployment credentials in the repository's Settings β†’ Secrets and reference them as ${{ secrets.MY_SECRET }} β€” never commit them to the workflow file.