CI/CD is not just about automation; it's about confidence. Setting up a high-reliability pipeline using GitHub Actions ensures that every pull request is linted, compiled, and verified before merging to production.
๐ฏ Designing the Workflow
A standard pipeline consists of three sequential checks: Code Quality (Linting), Verification (Testing), and Deployment.
name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
verify:
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: Code Quality Checks
run: npm run lint
- name: Run Jest Test Suite
run: npm run test -- --passWithNoTests
- name: Production Build Check
run: npm run build
deploy:
needs: verify
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Trigger Webhook / AWS App Runner / VPS Deploy
run: |
curl -X POST -H "Authorization: Bearer ${{ secrets.DEPLOY_TOKEN }}" https://api.muhammadtahasiddiqui.com/deploy๐ ๏ธ Performance Optimization for Runners
- โธDependency Caching: Leveraging
actions/setup-nodewith thecache: 'npm'configuration speeds up dependency installs by up to 70%. - โธParallelization: Run non-dependent tasks (like unit tests and formatting checks) in parallel using separate jobs to reduce pipeline execution time.
- โธEnvironment Isolation: Always use GitHub Secrets (
${{ secrets.XYZ }}) to manage credentials and injection parameters. Never hardcode API tokens or SSH keys in the YAML files.