Cloud, DevOps & Security 9 min read

CI/CD for Beginners: Automate Testing and Deployment with GitHub Actions

Understand CI/CD in simple terms, then build a GitHub Actions pipeline that installs dependencies, runs tests and lint, builds your app and deploys it to a server or platform — with secrets kept safe.

Umer Hasan

Umer Hasan

Co-Founder & CTO at Zapprex

CI/CD for Beginners: Automate Testing and Deployment with GitHub Actions
Table of contents

CI/CD in plain words

  • Continuous Integration (CI): every push runs automated checks — install, lint, test, build — so problems are caught in minutes.
  • Continuous Delivery/Deployment (CD): when checks pass on the main branch, the app is deployed automatically or with one approval.
  • The benefit: fewer “it worked on my machine” bugs, faster releases and no manual deployment mistakes.
At a glance: CI/CD in plain words — Continuous Integration (CI), Continuous Delivery/Deployment (CD), The benefit
At a glance: CI/CD in plain words

Build the pipeline

Build the pipeline: 6 steps
  1. 1

    Create the workflow file: add .github/workflows/ci.yml to your repository.

  2. 2

    Trigger on pushes and pull requests: run checks on every pull request and deploy only from main.

  3. 3

    Install and cache dependencies: use npm ci with the Node setup action’s cache.

  4. 4

    Run quality checks: lint, type-check and tests must pass before building.

  5. 5

    Build: produce the production bundle as an artifact.

  6. 6

    Deploy: from main only, using secrets stored in the repository or environment settings.

.github/workflows/ci.ymlyaml
name: CI
on:
  push: { branches: [main] }
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22, cache: npm }
      - run: npm ci
      - run: npm run lint
      - run: npm test --if-present
      - run: npm run build

  deploy:
    needs: build
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@v4
      - name: Deploy over SSH
        run: |
          echo "${{ secrets.DEPLOY_KEY }}" > key && chmod 600 key
          ssh -i key -o StrictHostKeyChecking=accept-new deploy@${{ secrets.SERVER_IP }} "cd app && ./deploy.sh"

Keep it safe

  • Secrets in GitHub settings: never commit keys; reference them as secrets in the workflow.
  • Protected environments: require approval for production deployments.
  • Branch protection: require passing checks and a review before merging to main.
  • Pin and update actions: use trusted actions and keep versions current.
  • Least privilege: deployment keys should only be able to deploy, nothing more.

Tip: Start with CI only (checks on pull requests). Add automatic deployment once the checks are reliable and your team trusts them.

Topics

CI/CDGitHub ActionsDevOpsAutomated Deployment
Umer Hasan
Written by

Umer Hasan

Co-Founder & CTO at Zapprex

Leads engineering, cloud infrastructure and AI automation at Zapprex Technologies, with 7+ years of full-stack and mobile experience.

FAQ

Questions readers ask

GitHub Actions includes free usage for public repositories and a monthly allowance for private repositories depending on your plan; heavier usage is billed.

Have a project in mind?

Let's build something that moves your business forward.

Share your idea, process or problem — we will come back with a clear plan, timeline and cost range. No technical spec needed.

  • Founder reply within 1 business day
  • NDA on request · 100% code ownership
  • Talk directly to the engineers