Programming

GitHub Actions CI/CD Pipeline

12 ديسمبر 202511 min read
GitHub Actions CI/CD Pipeline

Automate testing and deployment with GitHub Actions workflows.

What Is CI/CD?

CI = Continuous Integration (automated testing). CD = Continuous Deployment (automated deployment). Accelerates development and reduces errors.

Basic Workflow

# .github/workflows/ci.yml
name: CI

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

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
      - run: npm run build

Deployment Job

deploy:
  needs: test
  runs-on: ubuntu-latest
  if: github.ref == 'refs/heads/main'
  steps:
    - uses: actions/checkout@v4
    - name: Deploy to Production
      env:
        DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
      run: |
        npm run build
        npm run deploy

Matrix Testing

strategy:
  matrix:
    node-version: [18, 20, 22]
    os: [ubuntu-latest, windows-latest]

Conclusion

GitHub Actions is free for public repositories. Start simple and expand as needed.

Tags

#GitHub Actions#CI/CD#DevOps#Automation#Testing

Related Posts