CI/CD with GitHub Actions
Set up continuous integration and deployment pipelines using GitHub Actions for automated testing and deployments.
CI/CD with GitHub Actions
GitHub Actions provides a powerful CI/CD platform directly integrated with your GitHub repositories.
Basic Workflow
Create .github/workflows/ci.yml:
name: CI Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Build
run: npm run build
Key Concepts
Triggers
push: Trigger on push eventspull_request: Trigger on PR eventsschedule: Cron-based triggersworkflow_dispatch: Manual triggers
Jobs and Steps
Jobs run in parallel by default. Steps within a job run sequentially.
Secrets
Store sensitive data securely:
env:
API_KEY: ${{ secrets.API_KEY }}
Deployment Example
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to production
run: |
echo "Deploying to production..."
# Your deployment commands here
Best Practices
- Cache dependencies for faster builds
- Use matrix builds for testing across versions
- Keep secrets out of workflow files
- Use reusable workflows to reduce duplication
- Set up branch protection rules with required checks
Related Articles
Docker Fundamentals
A beginner-friendly guide to Docker — containers, images, Dockerfiles, and Docker Compose for modern development workflows.
Top 10 Developer Tools in 2026
My curated list of essential developer tools that have transformed my workflow in 2026 — from IDE setups to deployment pipelines.
Why I Switched to Astro for Documentation
My journey from Next.js to Astro for building developer documentation sites — why static-first wins for content-heavy sites.