GitHub Actions Workflow Cheat Sheet — CI/CD Pipeline Syntax

Ready-to-use workflow triggers (push, pull_request, schedule), matrix build strategies, secrets injection, caching, and deployment steps.

Workflow Triggers & Structure

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

Trigger pipeline automatically on commit push or PR against main branch

jobs: build: runs-on: ubuntu-latest

Define execution job running inside standard Linux VM container

- uses: actions/checkout@v4

Official action to clone your repository into the runner workspace

- uses: actions/setup-node@v4 with: node-version: 20 cache: "npm"

Install Node.js 20 runtime and automatically cache ~/.npm dependencies

Environment & Secrets

env: API_KEY: ${{ secrets.PROD_API_KEY }}

Securely inject repository secret into environment variable

strategy: matrix: node-version: [18.x, 20.x, 22.x]

Run test suite in parallel across multiple Node.js runtime versions