# GitHub Actions CI/CD Pipeline Mastery
## Introduction
GitHub Actions is the most popular CI/CD platform. This guide covers patterns that scale.
## Basic Workflow
“`yaml
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
– uses: actions/checkout@v4
– uses: actions/setup-node@v4
with:
node-version: ’20’
– run: npm ci
– run: npm test
“`
## Advanced Patterns
### Matrix Testing
“`yaml
jobs:
test:
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, windows-latest]
“`
### Caching
“`yaml
– uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles(‘**/package-lock.json’) }}
“`
## Deployment
### Production Deploy
“`yaml
– name: Deploy
if: github.ref == ‘refs/heads/main’
run: |
kubectl set image deployment/app app=${{ github.sha }}
“`
## Conclusion
GitHub Actions enables powerful automation. Start simple, add complexity as needed.
