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.

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.

Build the pipeline

- 1
Create the workflow file: add .github/workflows/ci.yml to your repository.
- 2
Trigger on pushes and pull requests: run checks on every pull request and deploy only from main.
- 3
Install and cache dependencies: use npm ci with the Node setup action’s cache.
- 4
Run quality checks: lint, type-check and tests must pass before building.
- 5
Build: produce the production bundle as an artifact.
- 6
Deploy: from main only, using secrets stored in the repository or environment settings.
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
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.
Keep reading
All articlesOTP Login Done Right: Security, Rate Limits, Autofill and SMS vs WhatsApp OTP
Build OTP login that is secure, cheap and pleasant: how OTPs should be generated and stored, rate limiting, SMS pumping fraud, autofill on Android, iOS and the web, and when to use WhatsApp or voice OTP.
Web Application Security Checklist: 25 Must-Do Steps Based on the OWASP Top 10
A practical, plain-English security checklist for websites and web apps: access control, injection, authentication, secrets, dependencies, headers, logging and backups — mapped to the OWASP Top 10.
API Security Best Practices: Authentication, Authorisation, Rate Limiting and More
How to secure REST and GraphQL APIs used by mobile apps and websites: tokens and keys, object-level authorisation, input validation, rate limits, CORS, webhooks and logging — with simple examples.
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.
With continuous delivery, every passing change is ready to deploy and released with a manual approval. With continuous deployment, it goes live automatically.
Yes. A workflow can deploy over SSH, upload files via SFTP or call your host’s deployment hooks, using secrets for credentials.
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
