CI/CD Pipelines: Foundations and Examples/Minimal GitHub Actions pipeline

Build and test on pushes and pull requests.

Section: Pipeline building blocks

Minimal GitHub Actions pipeline

yaml
yaml
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
          cache: npm
      - run: npm ci
      - run: npm test
      - run: npm run build
Explanation

Use this as a compact baseline for CI: checkout, install, test, and build.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Pipeline building blocks
Minimal GitLab CI pipeline
Run install, test, and build using stages.
OpenIn sheetyamlsame section
Minimal Jenkins declarative pipeline
Run checkout, install, test, and build in a Jenkinsfile.
OpenIn sheetgroovysame section
Validate pull requests only
Run CI before code reaches main.
Deploy only from main
Restrict production deployment to your protected main branch.
Nightly scheduled workflow
Run audits, backups, smoke tests, or dependency checks on a schedule.